Skip to content

Commit d59a1db

Browse files
Update the automation to bump erlang/elixir patches in CI (backport #7991) (#7996)
* Update the automation to bump erlang/elixir patches in CI so that the workflow fails if the branch already exists, instead of just skipping We had a period of many weeks where the elixir workflow was being skipped because the branch was left around after a PR was closed, so we want to avoid that in the future (cherry picked from commit bb6c503) # Conflicts: # .github/workflows/update-elixir-patches.yaml # .github/workflows/update-otp-patches.yaml * Fixup backport --------- Co-authored-by: Rin Kuryloski <[email protected]>
1 parent 98b413e commit d59a1db

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

.github/workflows/update-elixir-patches.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,20 @@ jobs:
1717
- elixir_version: "1.14"
1818
name: '1_14'
1919
timeout-minutes: 10
20+
env:
21+
branch: bump-elixir-${{ matrix.elixir_version }}
2022
steps:
2123
- name: CHECKOUT REPOSITORY
2224
uses: actions/checkout@v3
23-
- name: SKIP IF THE PR ALREADY EXISTS
25+
- name: FAIL IF THE PR ALREADY EXISTS
2426
id: check-for-branch
2527
run: |
2628
set +e
27-
git ls-remote --exit-code --heads origin bump-elixir-${{ matrix.elixir_version }}
28-
echo "::set-output name=c::$?"
29+
if git ls-remote --exit-code --heads origin ${{ env.branch }}; then
30+
echo "Branch ${{ env.branch }} already exits"
31+
exit 1
32+
fi
2933
- name: DETERMINE LATEST PATCH & SHA
30-
if: steps.check-for-branch.outputs.c != 0
3134
id: fetch-version
3235
run: |
3336
TAG_NAME=$(curl -s GET https://api.github.com/repos/elixir-lang/elixir/tags?per_page=100 \
@@ -47,10 +50,9 @@ jobs:
4750
exit 1
4851
fi
4952
50-
echo "::set-output name=VERSION::${TAG_NAME#v}"
51-
echo "::set-output name=SHA::${SHA}"
53+
echo "VERSION=${TAG_NAME#v}" >> $GITHUB_OUTPUT
54+
echo "SHA=${SHA}" >> $GITHUB_OUTPUT
5255
- name: MODIFY VERSION FILE
53-
if: steps.check-for-branch.outputs.c != 0
5456
run: |
5557
sudo npm install --global --silent @bazel/buildozer
5658
@@ -67,8 +69,7 @@ jobs:
6769
set -x
6870
git diff
6971
- name: CREATE PULL REQUEST
70-
if: steps.check-for-branch.outputs.c != 0
71-
uses: peter-evans/[email protected]
72+
uses: peter-evans/[email protected]
7273
with:
7374
token: ${{ secrets.REPO_SCOPED_TOKEN }}
7475
committer: GitHub <[email protected]>
@@ -84,6 +85,5 @@ jobs:
8485
labels: |
8586
backport-v3.11.x
8687
backport-v3.10.x
87-
backport-v3.9.x
88-
branch: bump-elixir-${{ matrix.elixir_version }}
88+
branch: ${{ env.branch }}
8989
delete-branch: true

.github/workflows/update-otp-patches.yaml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,22 @@ jobs:
4848
backport-v3.11.x
4949
backport-v3.10.x
5050
timeout-minutes: 10
51+
env:
52+
branch: bump-otp-${{ matrix.erlang_version }}
5153
steps:
5254
- name: CHECKOUT REPOSITORY
5355
uses: actions/checkout@v3
5456
with:
5557
ref: ${{ matrix.branch }}
56-
- name: SKIP IF THE PR ALREADY EXISTS
58+
- name: FAIL IF THE PR ALREADY EXISTS
5759
id: check-for-branch
5860
run: |
5961
set +e
60-
git ls-remote --exit-code --heads origin bump-otp-${{ matrix.erlang_version }}
61-
echo "::set-output name=c::$?"
62+
if git ls-remote --exit-code --heads origin ${{ env.branch }}; then
63+
echo "Branch ${{ env.branch }} already exits"
64+
exit 1
65+
fi
6266
- name: DETERMINE LATEST PATCH & SHA
63-
if: steps.check-for-branch.outputs.c != 0
6467
id: fetch-version
6568
run: |
6669
TAG_NAME=$(curl -s GET https://api.github.com/repos/erlang/otp/tags?per_page=100 \
@@ -90,11 +93,10 @@ jobs:
9093
exit 1
9194
fi
9295
93-
echo "::set-output name=VERSION::${VERSION}"
94-
echo "::set-output name=SHA::${SHA}"
95-
echo "::set-output name=SHA2::${SHA2}"
96+
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
97+
echo "SHA=${SHA}" >> $GITHUB_OUTPUT
98+
echo "SHA2=${SHA2}" >> $GITHUB_OUTPUT
9699
- name: MODIFY VERSION FILE
97-
if: steps.check-for-branch.outputs.c != 0
98100
run: |
99101
sudo npm install --global --silent @bazel/buildozer
100102
@@ -141,8 +143,7 @@ jobs:
141143
set -x
142144
git diff
143145
- name: CREATE PULL REQUEST
144-
if: steps.check-for-branch.outputs.c != 0
145-
uses: peter-evans/[email protected]
146+
uses: peter-evans/[email protected]
146147
with:
147148
token: ${{ secrets.REPO_SCOPED_TOKEN }}
148149
committer: GitHub <[email protected]>
@@ -156,5 +157,5 @@ jobs:
156157
commit-message: |
157158
Adopt otp ${{ steps.fetch-version.outputs.VERSION }}
158159
labels: ${{ matrix.labels }}
159-
branch: bump-otp-${{ matrix.erlang_version }}
160+
branch: ${{ env.branch }}
160161
delete-branch: true

0 commit comments

Comments
 (0)