Skip to content

Commit 55e6526

Browse files
committed
compatibility with bors
skip if S-waiting-on-bors never reopen a closed PR
1 parent 3997268 commit 55e6526

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

.github/workflows/dependencies.yml

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ defaults:
1414
run:
1515
shell: bash
1616
env:
17-
CARGO_UPGRADES_VER: --version=1.3.6
1817
PR_TITLE: Weekly `cargo update`
1918
PR_MESSAGE: |
2019
Automation to keep dependencies in `Cargo.lock` current.
@@ -23,6 +22,24 @@ env:
2322
COMMIT_MESSAGE: "cargo update \n\n"
2423

2524
jobs:
25+
waiting-on-bors:
26+
name: skip if S-waiting-on-bors
27+
runs-on: ubuntu-latest
28+
steps:
29+
- env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
run: |
32+
# Fetch state and labels of PR
33+
# Or exit successfully if PR does not exist
34+
JSON=$(gh pr view cargo_update --repo $GITHUB_REPOSITORY --json labels,state || exit 0)
35+
STATE=$(echo "$JSON" | jq -r '.state')
36+
WAITING_ON_BORS=$(echo "$JSON" | jq '.labels[] | any(.name == "S-waiting-on-bors"; .)')
37+
38+
# Exit with error if open and S-waiting-on-bors
39+
if [[ "$STATE" == "OPEN" && "$WAITING_ON_BORS" == "true" ]]; then
40+
exit 1
41+
fi
42+
2643
update:
2744
name: update dependencies
2845
runs-on: ubuntu-latest
@@ -93,19 +110,23 @@ jobs:
93110
git add ./Cargo.lock
94111
git commit --no-verify --file=commit.txt
95112
96-
- name: edit and reopen existing pull request
113+
- name: push
114+
run: git push --no-verify -f -u origin cargo_update
115+
116+
- name: edit existing open pull request
97117
id: edit
98118
# Don't fail job if we need to open new PR
99119
continue-on-error: true
100120
env:
101121
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102122
run: |
103-
gh pr edit cargo_update --title "${PR_TITLE}" --body-file body.md --repo $GITHUB_REPOSITORY
104-
gh pr reopen cargo_update --repo $GITHUB_REPOSITORY
123+
# Exit with error if PR is closed
124+
STATE=$(gh pr view cargo_update --repo $GITHUB_REPOSITORY --json state --jq '.state')
125+
if [[ "$STATE" != "OPEN" ]]; then
126+
exit 1
127+
fi
105128
106-
- name: push
107-
# Must push after reopening PR because of a Github quirk
108-
run: git push --no-verify -f -u origin cargo_update
129+
gh pr edit cargo_update --title "${PR_TITLE}" --body-file body.md --repo $GITHUB_REPOSITORY
109130
110131
- name: open new pull request
111132
# Only run if there wasn't an existing PR

0 commit comments

Comments
 (0)