Skip to content

Commit 6825ee8

Browse files
Update mavis-tech channel automatically post deployment
- Assume minor version updates - Use slack api action to publish topic updates
1 parent 5a789e3 commit 6825ee8

1 file changed

Lines changed: 33 additions & 3 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,10 @@ jobs:
345345
name: Notify deployment status
346346
runs-on: ubuntu-latest
347347
needs: [ deploy-service, run-migrations ]
348-
if: ${{ !cancelled() }}
348+
if: ${{ !cancelled() && inputs.environment == 'production' }}
349349
steps:
350350
- name: Notify deployment success
351-
if: ${{ env.environment == 'production' && needs.deploy-service.result == 'success' }}
351+
if: ${{ needs.deploy-service.result == 'success' }}
352352
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a
353353
with:
354354
webhook: ${{ secrets.SLACK_MAVIS_RELEASES_WEBHOOK_URL }}
@@ -360,8 +360,38 @@ jobs:
360360
text:
361361
type: "mrkdwn"
362362
text: "*${{ env.app_version }}* is deployed :ship:"
363+
- name: Checkout code
364+
if: ${{ needs.deploy-service.result == 'success' }}
365+
uses: actions/checkout@v6
366+
with:
367+
fetch-depth: 0
368+
- name: Generate slack channel topic
369+
if: ${{ needs.deploy-service.result == 'success' }}
370+
env:
371+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_MAVIS_TECH_WEBHOOK_URL }}
372+
run: |
373+
CURRENT_VERSION=${{ env.app_version }}
374+
major=${CURRENT_VERSION#v};
375+
major=${major%%.*};
376+
minor=${CURRENT_VERSION#v${major}.};
377+
minor=${minor%%.*};
378+
new_minor=$((minor+1));
379+
patch=${CURRENT_VERSION#v${major}.${minor}.};
380+
NEXT_VERSION=$(echo "v${major}.${new_minor}.${patch}")
381+
TOPIC="release: ${{ env.app_version }} - main: ${{ env.app_version }} - next: ${NEXT_VERSION}"
382+
echo "TOPIC=$TOPIC" >> $GITHUB_ENV
383+
- name: Update slack topic
384+
if: ${{ needs.deploy-service.result == 'success' }}
385+
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a
386+
with:
387+
method: conversations.setTopic
388+
token: ${{ secrets.MAVIS_DEPLOYMENT_BOT_OAUTH_TOKEN }}
389+
errors: true
390+
payload: |
391+
channel: ${{ secrets.MAVIS_TECH_CHANNEL_ID }}
392+
topic: "${{ env.TOPIC }}"
363393
- name: Notify deployment failure
364-
if: ${{ env.environment == 'production' && (needs.deploy-service.result == 'failure' || needs.run-migrations.result == 'failure') }}
394+
if: ${{ needs.deploy-service.result == 'failure' || needs.run-migrations.result == 'failure' }}
365395
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a
366396
with:
367397
webhook: ${{ secrets.SLACK_MAVIS_RELEASES_WEBHOOK_URL }}

0 commit comments

Comments
 (0)