Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions .github/workflows/dependabump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: dependabump.yml
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1-5' # every week-day at midnight
- cron: "0 0 * * 1-5" # every week-day at midnight

permissions:
contents: write
Expand All @@ -25,12 +25,15 @@ jobs:
id: changes
run: |
git add --all
git diff --cached --exit-code
echo "exit_code=$?" >> "$GITHUB_OUTPUT"
if git diff --cached --quiet; then
echo "changed=false" | tee -a "$GITHUB_OUTPUT"
else
echo "changed=true" | tee -a "$GITHUB_OUTPUT"
fi
continue-on-error: true

- name: Notify Fatal Error
if: !contains([0,1], steps.changes.outputs.exit_code != '0' ) # Fatal exit code
if: steps.changes.outcome == 'failure'
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh so I definitely biffed that old logic, but the point here was to catch failures other than 1. So I meant:

Suggested change
if: steps.changes.outcome == 'failure'
if: !contains([0,1], steps.changes.outputs.exit_code ) # Fatal exit code

w/o that leftover zero comparison. Does that make sense?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, yeah so 0 or 1 are expected and > 1 is a critical failure.

uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
with:
method: chat.postMessage
Expand All @@ -39,24 +42,25 @@ jobs:
channel: ${{ secrets.SLACK_TEAM_CORE_CHANNEL_ID}}
text: "Failed to run dependabump: <${{ format('https://github.com/{0}/actions/runs/{1}', github.repository, github.run_id) }}|Run>"

# - if: !contains([0,1], steps.changes.outputs.exit_code != '0' ) # Fatal exit code
# run: exit 1
# - if: steps.changes.outcome == 'failure'
# run: exit 1

- name: Create Pull Request & Notify
id: pr
if: steps.changes.outputs.exit_code == '1' # Changes detected
if: steps.changes.outputs.changed == 'true' # Changes detected
run: |
git switch -c dependabump/${{ GITHUB_EVENT_NAME }}-${{ GITHUB_RUN_ID }}
# TODO how to sign verified commit?
feature_branch_name="dependabump/${GITHUB_EVENT_NAME}-${GITHUB_RUN_ID}"
git switch -c "$feature_branch_name"
# TODO how to sign verified commit?
git commit -m "bump dependencies"
git push -u origin dependabump/${{ GITHUB_EVENT_NAME }}-${{ GITHUB_RUN_ID }}
git push -u origin "$feature_branch_name"
gh pr create --base main --title "dependabump" --body "Bumping deps due to critical or high vulnerabilities." | gh variable set url --body -
echo "exit_code=$?" >> "$GITHUB_OUTPUT"
echo "exit_code=$?" | tee -a "$GITHUB_OUTPUT"
# TODO (close stale dependabump/ branches?)
continue-on-error: true # Still notify

- name: Notify PR Failure
if: steps.changes.outputs.exit_code == '1' && steps.pr.outputs.exit_code != '0' # Changes detected but failed to create PR
if: steps.changes.outputs.changed == 'true' && steps.pr.outputs.exit_code != '0' # Changes detected but failed to create PR
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
with:
method: chat.postMessage
Expand All @@ -65,11 +69,11 @@ jobs:
channel: ${{ secrets.SLACK_TEAM_CORE_CHANNEL_ID}}
text: "Changes detected by dependabump, but failed to create PR: <${{ format('https://github.com/{0}/actions/runs/{1}', github.repository, github.run_id) }}|Run>"

- if: steps.changes.outputs.exit_code == '1' && steps.pr.outputs.exit_code != '0' # Changes detected but failed to create PR
- if: steps.changes.outputs.changed == 'true' && steps.pr.outputs.exit_code != '0' # Changes detected but failed to create PR
run: exit 1

- name: Notify PR Created
if: steps.changes.outputs.exit_code == '1' && steps.pr.outputs.exit_code == '0' # Changes detected and PR created
if: steps.changes.outputs.changed == 'true' && steps.pr.outputs.exit_code == '0' # Changes detected and PR created
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
with:
method: chat.postMessage
Expand Down
Loading