Skip to content

Commit b485f17

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

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+
contents: write
9+
pull-requests: write
10+
actions: read
11+
12+
jobs:
13+
dependabump:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v5
18+
with:
19+
ref: main
20+
21+
- name: Bump Dependencies
22+
run: make dependabot
23+
24+
- name: Detect Changes
25+
id: changes
26+
run: |
27+
git add --all
28+
git diff --cached --exit-code
29+
echo "exit_code=$?" >> "$GITHUB_OUTPUT"
30+
continue-on-error: true
31+
32+
- name: Notify Fatal Error
33+
if: !contains([0,1], steps.changes.outputs.exit_code != '0' ) # Fatal exit code
34+
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
35+
with:
36+
method: chat.postMessage
37+
token: ${{ secrets.QA_SLACK_API_KEY }}
38+
payload: |
39+
channel: ${{ secrets.SLACK_TEAM_CORE_CHANNEL_ID}}
40+
text: "Failed to run dependabump: <${{ format('https://github.com/{0}/actions/runs/{1}', github.repository, github.run_id) }}|Run>"
41+
exit 1
42+
43+
- name: Create Pull Request & Notify
44+
id: pr
45+
if: ${{ steps.changes.outputs.exit_code == '1' }} # Changes detected
46+
run: |
47+
git switch -c dependabump/${{ GITHUB_EVENT_NAME }}-${{ GITHUB_RUN_ID }}
48+
# TODO how to sign verified commit?
49+
git commit -m "bump dependencies"
50+
git push -u origin dependabump/${{ GITHUB_EVENT_NAME }}-${{ GITHUB_RUN_ID }}
51+
gh pr create --base main --title "chore: bump dependencies" --body "This PR was automatically created by dependabump.yml" | tee | gh variable set url --body -
52+
echo "exit_code=$?" >> "$GITHUB_OUTPUT"
53+
# TODO (close stale dependabump/ branches?)
54+
continue-on-error: true # Still notify
55+
56+
- name: Notify PR Failure
57+
if: ${{ steps.changes.outputs.exit_code == '1' && steps.pr.outputs.exit_code != '0' }} # Changes detected but failed to create PR
58+
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
59+
with:
60+
method: chat.postMessage
61+
token: ${{ secrets.QA_SLACK_API_KEY }}
62+
payload: |
63+
channel: ${{ secrets.SLACK_TEAM_CORE_CHANNEL_ID}}
64+
text: "Changes detected by dependabump, but failed to create PR: <${{ format('https://github.com/{0}/actions/runs/{1}', github.repository, github.run_id) }}|Run>"
65+
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)