Merge pull request #144 from team-ppointer/feat/git-workflow/expo-deploy #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy to EC2 and Notify Slack | |
| on: | |
| push: | |
| branches: | |
| - native | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Deploy to EC2 | |
| uses: appleboy/ssh-action@master | |
| env: | |
| REPO_PATH: /home/ubuntu/Pointer | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| envs: REPO_PATH | |
| script: | | |
| cd $REPO_PATH | |
| echo "Pulling latest changes..." | |
| git pull origin native | |
| echo "Installing dependencies..." | |
| cd apps/native | |
| npm install | |
| pm2 restart expo | |
| echo "✅ Deployment completed!" | |
| - name: Prepare commit message | |
| if: always() | |
| id: commit | |
| run: | | |
| COMMIT_MSG=$(echo '${{ github.event.head_commit.message }}' | head -n 1 | sed 's/"/\\"/g' | sed "s/'/\\'/g") | |
| echo "message=$COMMIT_MSG" >> $GITHUB_OUTPUT | |
| - name: Notify Slack - Success | |
| if: success() | |
| uses: slackapi/slack-github-action@v1.26.0 | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK | |
| with: | |
| payload: | | |
| { | |
| "text": "✅ Expo Deployment Success", | |
| "blocks": [ | |
| { | |
| "type": "header", | |
| "text": { | |
| "type": "plain_text", | |
| "text": "✅ Expo Deployment Successful" | |
| } | |
| }, | |
| { | |
| "type": "section", | |
| "fields": [ | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Repository:* ${{ github.repository }}" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Branch:* ${{ github.ref_name }}" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Author:* ${{ github.event.head_commit.author.name }}" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Commit:* ${{ steps.commit.outputs.message }}" | |
| } | |
| ] | |
| }, | |
| { | |
| "type": "section", | |
| "text": { | |
| "type": "mrkdwn", | |
| "text": "<${{ github.event.head_commit.url }}|View Commit>" | |
| } | |
| } | |
| ] | |
| } | |
| - name: Notify Slack - Failure | |
| if: failure() | |
| uses: slackapi/slack-github-action@v1.26.0 | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK | |
| with: | |
| payload: | | |
| { | |
| "text": "❌ Expo Deployment Failed", | |
| "blocks": [ | |
| { | |
| "type": "header", | |
| "text": { | |
| "type": "plain_text", | |
| "text": "❌ Expo Deployment Failed" | |
| } | |
| }, | |
| { | |
| "type": "section", | |
| "fields": [ | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Repository:* ${{ github.repository }}" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Branch:* ${{ github.ref_name }}" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Author:* ${{ github.event.head_commit.author.name }}" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Commit:* ${{ steps.commit.outputs.message }}" | |
| } | |
| ] | |
| }, | |
| { | |
| "type": "section", | |
| "text": { | |
| "type": "mrkdwn", | |
| "text": "⚠️ Check the <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|workflow logs>" | |
| } | |
| } | |
| ] | |
| } |