1919jobs :
2020 deploy :
2121 name : Deploy
22- runs-on : ${{ vars.DEFAULT_ACTIONS_IMAGE }}
22+ runs-on : ubuntu-22.04
2323 environment : production
2424
2525 steps :
2626 - name : Checkout code
2727 uses : actions/checkout@v4
2828
29+ - name : Determine Slack Config
30+ id : slack_config
31+ run : |
32+ if [ "true" == "true" ]; then
33+ echo "slack_channel=${{ vars.SLACK_CH_TEST }}" >> $GITHUB_ENV
34+ echo "slack_token=${{ secrets.SLACK_BOT_TOKEN_TEST }}" >> $GITHUB_ENV
35+ else
36+ echo "slack_channel=${{ vars.SLACK_CH_TECH_DEPLOY }}" >> $GITHUB_ENV
37+ echo "slack_token=${{ secrets.SLACK_BOT_TOKEN }}" >> $GITHUB_ENV
38+ fi
39+
2940 - name : Configure AWS credentials
3041 uses : aws-actions/configure-aws-credentials@v4
3142 with :
@@ -38,40 +49,38 @@ jobs:
3849 with :
3950 node-version : 10
4051
52+ - name : Notify start of Deployment in Slack
53+ id : deployment_message
54+ uses : slackapi/slack-github-action@v2.0.0
55+ with :
56+ method : chat.postMessage
57+ token : ${{ env.slack_token }}
58+ payload : |
59+ channel: ${{ env.slack_channel }}
60+ text: |
61+ :rocket: *Deploy iniciado*
62+ *Repo:* <${{ github.event.repository.html_url }}|${{ github.event.repository.name }}>
63+ *Branch:* ${{ github.ref_name }}
64+ *Commit:* ${{ github.event.head_commit.url }}
65+ *Responsável:* ${{ github.actor }}
66+
4167 - name : Project | PreBuild
4268 run : |
43- if [ "${{ github.event.inputs.dry_run }}" == "true" ]; then
44- echo "Dry-run: Would have run 'npm run deps'"
45- else
46- npm run deps
47- fi
69+ npm run deps
4870
4971 - name : Project | Build
72+ run : |
73+ npm run build
74+
75+ - name : Sync Build to S3
5076 run : |
5177 if [ "${{ github.event.inputs.dry_run }}" == "true" ]; then
52- echo "Dry-run: Would have run 'npm run build'"
78+ echo "Dry-run: Would have synced ./dist/v7/ to s3://cdn.ingresse.com/websdk/v7"
79+ aws s3 cp ./dist/v7/ s3://cdn.ingresse.com/websdk/v7 --recursive --dryrun
5380 else
54- npm run build
81+ aws s3 cp ./dist/v7/ s3://cdn.ingresse.com/websdk/v7 --recursive
5582 fi
5683
57- - name : Prepare Upload Directory
58- run : |
59- mkdir -p ./dist/websdk/v7
60- mv ./dist/v7/* ./dist/websdk/v7/
61-
62- - name : Deploy
63- if : github.event.inputs.dry_run != 'true'
64- uses : reggionick/s3-deploy@v4
65- with :
66- folder : ./dist/websdk
67- bucket : cdn.ingresse.com
68- bucket-region : ${{ vars.AWS_REGION }}
69- dist-id : ${{ vars.CF_DISTRIBUTION_ID }}
70- invalidation : /
71- delete-removed : true
72- no-cache : true
73- private : true
74-
7584 - name : Invalidate CloudFront Cache
7685 env :
7786 CFID : ${{ vars.CF_DISTRIBUTION_ID }}
@@ -96,3 +105,27 @@ jobs:
96105 ]
97106 }'
98107 fi
108+
109+ - name : Notify success of deployment in Slack
110+ uses : slackapi/slack-github-action@v2.0.0
111+ if : success()
112+ with :
113+ method : chat.postMessage
114+ token : ${{ env.slack_token }}
115+ payload : |
116+ channel: ${{ env.slack_channel }}
117+ thread_ts: "${{ steps.deployment_message.outputs.ts }}"
118+ type: "in_thread"
119+ text: ":white_check_mark: *Deploy concluído*\n*App:* Backoffice-Web\n*Ambiente:* Production"
120+
121+ - name : Notify failure of deployment in Slack
122+ uses : slackapi/slack-github-action@v2.0.0
123+ if : failure()
124+ with :
125+ method : chat.postMessage
126+ token : ${{ env.slack_token }}
127+ payload : |
128+ channel: ${{ env.slack_channel }}
129+ thread_ts: "${{ steps.deployment_message.outputs.ts }}"
130+ type: "in_thread"
131+ text: ":x: *Deploy falhou*\n*App:* Backoffice-Web\n*Ambiente:* Production"
0 commit comments