@@ -24,31 +24,80 @@ concurrency: pr-${{ github.ref }}
2424
2525jobs :
2626# Dependabot is annoying, but this makes it a bit less so.
27- dependabot :
27+ dependabot-automerge :
2828runs-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'
3030permissions :
3131pull-requests :write
32- steps :
32+ steps :
3333 -name :Dependabot metadata
3434id :metadata
35- uses :dependabot/fetch-metadata@4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d # v2.2.0
35+ uses :dependabot/fetch-metadata@dbb049abf0d677abbd7f7eee0375145b417fdd34 # v2.2.0
3636with :
3737github-token :" ${{ secrets.GITHUB_TOKEN }}"
38-
38+
3939 -name :Approve the PR
4040run :gh pr review --approve "$PR_URL"
4141env :
4242PR_URL :${{github.event.pull_request.html_url}}
4343GH_TOKEN :${{secrets.GITHUB_TOKEN}}
44-
44+
4545 -name :Enable auto-merge for Dependabot PRs
4646if :steps.metadata.outputs.update-type == 'version-update:semver-patch'
4747run :gh pr merge --auto --merge "$PR_URL"
4848env :
4949PR_URL :${{github.event.pull_request.html_url}}
5050GH_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+ env :
59+ PR_URL :${{github.event.pull_request.html_url}}
60+ PR_TITLE :${{github.event.pull_request.title}}
61+ PR_NUMBER :${{github.event.pull_request.number}}
62+ run :|
63+ curl -X POST -H 'Content-type: application/json' \
64+ --data '{
65+ "username": "dependabot",
66+ "icon_url": "https://avatars.githubusercontent.com/u/27347476",
67+ "blocks": [
68+ {
69+ "type": "header",
70+ "text": {
71+ "type": "plain_text",
72+ "text": ":pr-merged: Auto merged Dependabot PR #${{ env.PR_NUMBER }}",
73+ "emoji":true
74+ }
75+ },
76+ {
77+ "type": "section",
78+ "fields": [
79+ {
80+ "type": "mrkdwn",
81+ "text": "${{ env.PR_TITLE }}"
82+ }
83+ ]
84+ },
85+ {
86+ "type": "actions",
87+ "elements": [
88+ {
89+ "type": "button",
90+ "text": {
91+ "type": "plain_text",
92+ "text": "View PR"
93+ },
94+ "url": "${{ env.PR_URL }}"
95+ }
96+ ]
97+ }
98+ ]
99+ }' ${{ secrets.DEPENDABOT_PRS_SLACK_WEBHOOK }}
100+
52101cla :
53102runs-on :ubuntu-latest
54103permissions :