Skip to content

Commit 43757cf

Browse files
committed
Handle feature branch separately from PR
1 parent 1f6f1fc commit 43757cf

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

.github/workflows/prepare-release.yml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,19 @@ jobs:
5757
echo "Release branch rc/$RELEASE_VERSION does not exist."
5858
echo "create_release_branch=true" >> "$GITHUB_ENV"
5959
echo "create_release_pr=true" >> "$GITHUB_ENV"
60+
echo "create_release_feature_branch=true" >> "$GITHUB_ENV"
6061
else
6162
echo "Release branch rc/$RELEASE_VERSION already exists."
6263
echo "create_release_branch=false" >> "$GITHUB_ENV"
6364
65+
if [[ -z $(git ls-remote --heads origin feature/update-user-manual-for-$RELEASE_VERSION) ]]; then
66+
echo "Feature branch feature/update-user-manual-for-$RELEASE_VERSION does not exist."
67+
echo "create_release_feature_branch=true" >> "$GITHUB_ENV"
68+
else
69+
echo "Feature branch feature/update-user-manual-for-$RELEASE_VERSION already exists."
70+
echo "create_release_feature_branch=false" >> "$GITHUB_ENV"
71+
fi
72+
6473
pr_state=$(gh pr view rc/$RELEASE_VERSION --json title,state)
6574
pr_title=$(echo "$pr_state" | jq -r '.title')
6675
pr_state=$(echo "$pr_state" | jq -r '.state')
@@ -77,6 +86,11 @@ jobs:
7786
7887
fi
7988
89+
- name: Configure git
90+
run: |
91+
git config user.name "$GITHUB_ACTOR"
92+
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
93+
8094
- name: Install Python
8195
uses: actions/setup-python@v4
8296
with:
@@ -109,13 +123,13 @@ jobs:
109123
$RELEASE_VERSION
110124
111125
- name: Create feature branch for PR
112-
if: env.create_release_pr == 'true'
126+
if: env.create_release_feature_branch == 'true'
113127
run: |
114128
git switch -c feature/update-user-manual-for-$RELEASE_VERSION
115129
git push --set-upstream origin feature/update-user-manual-for-$RELEASE_VERSION
116130
117131
- name: Get feature branch for PR
118-
if: env.create_release_pr == 'false'
132+
if: env.create_release_feature_branch == 'false'
119133
run: |
120134
git fetch origin feature/update-user-manual-for-$RELEASE_VERSION
121135
git switch feature/update-user-manual-for-$RELEASE_VERSION
@@ -129,7 +143,7 @@ jobs:
129143
find docs -name 'user_manual.md' | xargs sed -i "s/user_manual_.*\.md\`/user_manual_$RELEASE_VERSION.md\`/"
130144
find docs -name 'user_manual.md' | xargs sed -i "s/This user manual documents release \`.*\` of/This user manual documents release \`$RELEASE_VERSION\` of/"
131145
132-
if git diff --quiet; then
146+
if ! git diff --quiet; then
133147
git add -u .
134148
git commit -m "Update version"
135149
git push
@@ -146,16 +160,4 @@ jobs:
146160
--body "This PR releases codeql-coding-standards version $RELEASE_VERSION." \
147161
--base rc/$RELEASE_VERSION \
148162
--head feature/update-user-manual-for-$RELEASE_VERSION \
149-
--draft
150-
151-
- name: Determine pull request head SHA
152-
id: determine-pr-head-sha
153-
env:
154-
GITHUB_TOKEN: ${{ github.token }}
155-
run: |
156-
read -r pull_request_head_sha pr_state < <(gh pr view rc/$RELEASE_VERSION --json headRefOid,state --jq '.headRefOid + " " + .state')
157-
if [[ "$pr_state" != "OPEN" ]]; then
158-
echo "Release PR for rc/$RELEASE_VERSION is not open, but in state '$pr_state'. Cannot proceed!"
159-
exit 1
160-
fi
161-
echo "pull-request-head-sha=$pull_request_head_sha" >> "$GITHUB_OUTPUT"
163+
--draft

0 commit comments

Comments
 (0)