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

Announce in Slack if automerge fails because PR is not mergeable #1873

Merged
merged 5 commits into from
Mar 18, 2021
Merged
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
28 changes: 25 additions & 3 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,28 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}

# This Slack step is duplicated in all workflows, if you make a change to this step, make sure to update all
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we remove all the other instances? Can we exit the job here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rearranged so we fail the workflow then this announce step happens. However, I think we should leave the other announce steps in case the 3rd-party auto-approve and auto-merge actions fail for some other reason we're not aware of.

# the other workflows with the same change
- uses: 8398a7/action-slack@v3
name: Job failed Slack notification
if: ${{ steps.isPullRequestMergeable.outputs.IS_MERGEABLE == 'false' }}
with:
status: custom
fields: workflow, repo
custom_payload: |
{
channel: '#announce',
attachments: [{
color: "#DB4545",
pretext: `<!here>`,
text: `💥 ${process.env.AS_REPO} failed on ${process.env.AS_WORKFLOW} workflow 💥`,
}]
}
env:
GITHUB_TOKEN: ${{ github.token }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}


master:
runs-on: ubuntu-latest
needs: getPullRequestMergeability
Expand All @@ -48,7 +70,7 @@ jobs:
- name: Check for an auto merge
# Version: 0.12.0
uses: pascalgn/automerge-action@c9bd1823770819dc8fb8a5db2d11a3a95fbe9b07
if: needs.getPullRequestMergeability.outputs.isMergeable == 'true' && github.event.pull_request.mergeable_state == 'clean'
if: needs.getPullRequestMergeability.outputs.isMergeable == 'true'
env:
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}

Expand Down Expand Up @@ -88,7 +110,7 @@ jobs:
- name: Check for an auto merge
# Version: 0.12.0
uses: pascalgn/automerge-action@c9bd1823770819dc8fb8a5db2d11a3a95fbe9b07
if: needs.getPullRequestMergeability.outputs.isMergeable == 'true' && github.event.pull_request.mergeable_state == 'clean'
if: needs.getPullRequestMergeability.outputs.isMergeable == 'true'
env:
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}

Expand Down Expand Up @@ -128,7 +150,7 @@ jobs:
- name: Check for an auto merge
# Version: 0.12.0
uses: pascalgn/automerge-action@c9bd1823770819dc8fb8a5db2d11a3a95fbe9b07
if: needs.getPullRequestMergeability.outputs.isMergeable == 'true' && github.event.pull_request.mergeable_state == 'clean'
if: needs.getPullRequestMergeability.outputs.isMergeable == 'true'
env:
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}

Expand Down