Skip to content

Commit f5ce79c

Browse files
mesh-2770: add slack alert for failed pr
1 parent 58b3c5f commit f5ce79c

2 files changed

Lines changed: 32 additions & 26 deletions

File tree

.github/workflows/dependabot-auto-merge.yaml

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,27 @@ on:
1212
jobs:
1313
enable-automerge:
1414
# Only run on Dependabot PRs
15-
# if: github.event.pull_request.user.login == 'dependabot[bot]'
15+
if: github.event.pull_request.user.login == 'dependabot[bot]'
1616
runs-on: ubuntu-latest
1717
permissions:
1818
contents: write
1919
pull-requests: write
2020

2121
steps:
22-
# - name: Fetch Dependabot metadata
23-
# id: metadata
24-
# uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7
25-
# with:
26-
# github-token: ${{ secrets.GITHUB_TOKEN }}
27-
28-
# - name: Auto-approve Dependabot PR
29-
# if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
30-
# uses: hmarr/auto-approve-action@v4
31-
# with:
32-
# github-token: ${{ secrets.GITHUB_TOKEN }}
22+
- name: Fetch Dependabot metadata
23+
id: metadata
24+
uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7
25+
with:
26+
github-token: ${{ secrets.GITHUB_TOKEN }}
3327

34-
# - name: Enable auto-merge for Dependabot PRs
35-
# if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
36-
# run: gh pr merge --auto --squash "$PR_URL"
37-
# env:
38-
# PR_URL: ${{ github.event.pull_request.html_url }}
39-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
41-
- name: Slack Notification
42-
uses: slackapi/slack-github-action@v2.1.1
28+
- name: Auto-approve Dependabot PR
29+
uses: hmarr/auto-approve-action@v4
4330
with:
44-
webhook: ${{ secrets.DEPENDABOT_SLACK_WEBHOOK_URL }}
45-
webhook-type: incoming-webhook
46-
payload: |
47-
text : Hello from github
48-
31+
github-token: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Enable auto-merge for Dependabot PRs
34+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
35+
run: gh pr merge --auto --squash "$PR_URL"
36+
env:
37+
PR_URL: ${{ github.event.pull_request.html_url }}
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pull-request.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,19 @@ jobs:
312312
313313
- name: poetry test publish
314314
run: poetry publish -r testpypi
315+
316+
slack-notification:
317+
runs-on: ubuntu-latest
318+
needs:
319+
- coverage
320+
- lint
321+
- publish
322+
if: ${{ always() && github.repository == 'NHSDigital/mesh-sandbox' && github.actor == 'dependabot[bot]' && contains(needs.*.result, 'failure') }}
323+
steps:
324+
- name: Slack Notification
325+
uses: slackapi/slack-github-action@v2.1.1
326+
with:
327+
webhook: ${{ secrets.DEPENDABOT_SLACK_WEBHOOK_URL }}
328+
webhook-type: incoming-webhook
329+
payload: |
330+
text : "Dependabot PR checks failed for ${{ github.repository }}:${{ github.ref }} in PR #${{ github.event.number }}"

0 commit comments

Comments
 (0)