Skip to content

Commit bb292dd

Browse files
committed
.github/workflows: add dependabump
1 parent 29c0bf1 commit bb292dd

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

.github/workflows/dependabump.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: dependabump.yml
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
- cron: '0 0 * * 1-5' # every week-day at midnight
6+
7+
permissions: { }
8+
9+
jobs:
10+
dependabump:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v5
15+
with:
16+
ref: main
17+
18+
- name: Bump Dependencies
19+
run: make dependabot
20+
21+
- name: Detect Changes
22+
id: changes
23+
run: |
24+
git add --all
25+
git diff --cached --exit-code
26+
echo "exit_code=$?" >> "$GITHUB_OUTPUT"
27+
continue-on-error: true
28+
29+
- name: Notify Fatal Error
30+
if: ${{ !contains(fromJson('[0,1]'), steps.changes.outputs.exit_code ) }} # Fatal exit code
31+
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
32+
with:
33+
method: chat.postMessage
34+
token: ${{ secrets.QA_SLACK_API_KEY }}
35+
payload: |
36+
channel: ${{ secrets.SLACK_TEAM_CORE_CHANNEL_ID}}
37+
text: "Failed to run dependabump: <${{ format('https://github.com/{0}/actions/runs/{1}', github.repository, github.run_id) }}|Run>"
38+
39+
- if: ${{ !contains(fromJson('[0,1]'), steps.changes.outputs.exit_code ) }} # Fatal exit code
40+
run: exit 1
41+
42+
- name: Create Pull Request & Notify
43+
id: pr
44+
if: steps.changes.outputs.exit_code == '1' # Changes detected
45+
run: |
46+
git switch -c dependabump/${{ env.GITHUB_EVENT_NAME }}-${{ env.GITHUB_RUN_ID }}
47+
git commit -m "bump dependencies" # TODO how to sign verified commit?
48+
git push -u origin dependabump/${{ env.GITHUB_EVENT_NAME }}-${{ env.GITHUB_RUN_ID }}
49+
gh pr create --base main --title "dependabump" --body "Bumping deps due to critical or high vulnerabilities." | gh variable set url --body -
50+
echo "exit_code=$?" >> "$GITHUB_OUTPUT"
51+
continue-on-error: true # Still notify
52+
# TODO (close stale dependabump/ branches?)
53+
54+
- name: Notify PR Failure
55+
if: steps.changes.outputs.exit_code == '1' && steps.pr.outputs.exit_code != '0' # Changes detected but failed to create PR
56+
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
57+
with:
58+
method: chat.postMessage
59+
token: ${{ secrets.QA_SLACK_API_KEY }}
60+
payload: |
61+
channel: ${{ secrets.SLACK_TEAM_CORE_CHANNEL_ID}}
62+
text: "Changes detected by dependabump, but failed to create PR: <${{ format('https://github.com/{0}/actions/runs/{1}', github.repository, github.run_id) }}|Run>"
63+
64+
- if: steps.changes.outputs.exit_code == '1' && steps.pr.outputs.exit_code != '0' # Changes detected but failed to create PR
65+
run: exit 1
66+
67+
- name: Notify PR Created
68+
if: steps.changes.outputs.exit_code == '1' && steps.pr.outputs.exit_code == '0' # Changes detected and PR created
69+
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
70+
with:
71+
method: chat.postMessage
72+
token: ${{ secrets.QA_SLACK_API_KEY }}
73+
payload: |
74+
channel: ${{ secrets.SLACK_TEAM_CORE_CHANNEL_ID}}
75+
text: "Changes detected by dependabump: <${{ format('https://github.com/{0}/actions/runs/{1}', github.repository, github.run_id) }}|Run> - <${gh.variable.url}|PR> :review_time:"

0 commit comments

Comments
 (0)