Skip to content

Commit 986f23e

Browse files
committed
Cancel cargo update job if there's no changes
1 parent 3cdcdaf commit 986f23e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

.github/workflows/dependencies.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
4343
# Exit with error if open and S-waiting-on-bors
4444
if [[ "$STATE" == "OPEN" && "$WAITING_ON_BORS" == "true" ]]; then
45-
exit 1
45+
gh run cancel ${{ github.run_id }}
4646
fi
4747
4848
update:
@@ -65,7 +65,10 @@ jobs:
6565
6666
- name: cargo update
6767
# Remove first line that always just says "Updating crates.io index"
68-
run: cargo update 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
68+
# If there are no changes, cancel the job here
69+
run: |
70+
cargo update 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
71+
git status --porcelain | grep -q Cargo.lock || gh run cancel ${{ github.run_id }}
6972
- name: upload Cargo.lock artifact for use in PR
7073
uses: actions/upload-artifact@v3
7174
with:
@@ -131,7 +134,7 @@ jobs:
131134
# Exit with error if PR is closed
132135
STATE=$(gh pr view cargo_update --repo $GITHUB_REPOSITORY --json state --jq '.state')
133136
if [[ "$STATE" != "OPEN" ]]; then
134-
exit 1
137+
gh run cancel ${{ github.run_id }}
135138
fi
136139
137140
gh pr edit cargo_update --title "${PR_TITLE}" --body-file body.md --repo $GITHUB_REPOSITORY

0 commit comments

Comments
 (0)