Skip to content

Commit 802965d

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

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

.github/workflows/dependabump.yml

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