Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DR-3406: Update slack notify action: Correct branch; Move status check to action call #1588

Merged
merged 3 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/dev-image-update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ jobs:
needs: [ update_image, helm_tag_bump, cherry_pick_image_to_production_gcr ]
uses: ./.github/workflows/notify-slack.yaml
secrets: inherit
if: ${{ !cancelled() }}
with:
workflow_name: Dev Image Update
notify_on_success: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this parameter still make sense? In the false case wouldn't the workflow no longer be called?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are three states that we can check for here - success, failure or cancelled. (Cancelled being when the job is canceled manually by a user). So, the !cancelled() check means that it will run either on success on failure.

It's a little clunky, but it is the suggested option in the github actions docs.

If you want to run a job or step regardless of its success or failure, use the recommended alternative: if: ${{ !cancelled() }}

But, given that it's confusing, I think I'll just switch to always() and then cancelled jobs will just get the failure notification.

success: ${{ needs.update_image.result == 'success' && needs.helm_tag_bump.result == 'success' && needs.cherry_pick_image_to_production_gcr.result == 'success' }}
2 changes: 2 additions & 0 deletions .github/workflows/helmtagbump.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ jobs:
needs: [ integration_helm_tag_update, ui_helm_default_chart_tag ]
uses: ./.github/workflows/notify-slack.yaml
secrets: inherit
if: ${{ !cancelled() }}
with:
workflow_name: Helm Tag Bump
notify_on_failure: ${{ inputs.notify-slack }}
notify_on_success: ${{ inputs.notify-slack }}
success: ${{ needs.integration_helm_tag_update.result == 'success' && needs.ui_helm_default_chart_tag.result == 'success' }}

9 changes: 6 additions & 3 deletions .github/workflows/notify-slack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ env:
on:
workflow_call:
inputs:
success:
required: true
type: boolean
workflow_name:
required: true
type: string
Expand All @@ -27,10 +30,10 @@ on:
jobs:
notify-slack:
runs-on: ubuntu-latest
if: ${{ !cancelled() && github.ref == 'refs/heads/dev' }}
if: ${{ github.ref == 'refs/heads/develop' }}
steps:
- name: Notify slack on failure
if: inputs.notify_on_failure && failure()
if: ${{ inputs.notify_on_failure && !inputs.success }}
uses: slackapi/[email protected]
with:
channel-id: ${{ inputs.failure_slack_channel_id }}
Expand All @@ -55,7 +58,7 @@ jobs:
env:
SLACK_BOT_TOKEN: ${{ env.SLACK_BOT_TOKEN}}
- name: Notify slack on Success
if: inputs.notify_on_success && success()
if: ${{ inputs.notify_on_success && inputs.success }}
uses: slackapi/[email protected]
with:
channel-id: ${{ inputs.success_slack_channel_id }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ jobs:
needs: [e2e_test]
uses: ./.github/workflows/notify-slack.yaml
secrets: inherit
if: ${{ !cancelled() }}
with:
workflow_name: Nightly E2E Tests
notify_on_success: true
failure_slack_channel_id: "CMYTGJVFY,C53JYBV9A" # #jade-alerts & #dsde-qa
success_slack_channel_id: "CK9M0ENRJ,C53JYBV9A" # #jade-spam & #dsde-qa
success: ${{ needs.e2e_test.result == 'success' }}
2 changes: 2 additions & 0 deletions .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ jobs:
needs: [ unit_test ]
uses: ./.github/workflows/notify-slack.yaml
secrets: inherit
if: ${{ !cancelled() }}
with:
workflow_name: Nightly Unit Tests
notify_on_success: true
success: ${{ needs.unit_test.result == 'success' }}
Loading