Skip to content

Commit 423f176

Browse files
committed
chore: notify on auto merged dependabot PRs
1 parent f495ff0 commit 423f176

File tree

1 file changed

+49
-6
lines changed

1 file changed

+49
-6
lines changed

.github/workflows/contrib.yaml

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,74 @@ concurrency: pr-${{ github.ref }}
2424

2525
jobs:
2626
# Dependabot is annoying, but this makes it a bit less so.
27-
dependabot:
27+
dependabot-automerge:
2828
runs-on: ubuntu-latest
29-
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'coder/coder'
29+
if: github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'coder/coder'
3030
permissions:
3131
pull-requests: write
32-
steps:
32+
steps:
3333
- name: Dependabot metadata
3434
id: metadata
35-
uses: dependabot/fetch-metadata@4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d # v2.2.0
35+
uses: dependabot/fetch-metadata@dbb049abf0d677abbd7f7eee0375145b417fdd34 # v2.2.0
3636
with:
3737
github-token: "${{ secrets.GITHUB_TOKEN }}"
38-
38+
3939
- name: Approve the PR
4040
run: gh pr review --approve "$PR_URL"
4141
env:
4242
PR_URL: ${{github.event.pull_request.html_url}}
4343
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
44-
44+
4545
- name: Enable auto-merge for Dependabot PRs
4646
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
4747
run: gh pr merge --auto --merge "$PR_URL"
4848
env:
4949
PR_URL: ${{github.event.pull_request.html_url}}
5050
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
5151

52+
dependabot-automerge-notify:
53+
# Send a slack notification when a dependabot PR is merged.
54+
runs-on: ubuntu-latest
55+
if: github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'coder/coder' && github.event.pull_request.merged
56+
steps:
57+
- name: Send Slack notification
58+
run: |
59+
curl -X POST -H 'Content-type: application/json' \
60+
--data '{
61+
"blocks": [
62+
{
63+
"type": "header",
64+
"text": {
65+
"type": "plain_text",
66+
"text": ":pr-merged: Dependabot PR auto merged",
67+
"emoji": true
68+
}
69+
},
70+
{
71+
"type": "section",
72+
"fields": [
73+
{
74+
"type": "mrkdwn",
75+
"text": "${{ github.event.pull_request.title }}"
76+
}
77+
]
78+
},
79+
{
80+
"type": "actions",
81+
"elements": [
82+
{
83+
"type": "button",
84+
"text": {
85+
"type": "plain_text",
86+
"text": "View PR"
87+
},
88+
"url": "${{ github.event.pull_request.html_url }}"
89+
}
90+
]
91+
}
92+
]
93+
}' ${{ secrets.DEPENDABOT_PRS_SLACK_WEBHOOK }}
94+
5295
cla:
5396
runs-on: ubuntu-latest
5497
permissions:

0 commit comments

Comments
 (0)