Skip to content

Commit ea52323

Browse files
committed
Fix detection of the ci/no-release label in a push event
The release-main workflow is triggered by "push" event which does not carry `github.event.pull_request.labels`. Here we switch to GitHub CLI to lookup the PR from commit and test for the "ci/no-release" label. Note `gh pr list --search=COMMIT` may give several matches hence the extra check with `grep "${GITHUB_SHA}"`. Follow-up to #7915
1 parent bf22232 commit ea52323

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

.github/workflows/release-main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ jobs:
3535
envsubst < dev_tools/packaging/pypirc_template > $HOME/.pypirc
3636
- name: Build and publish
3737
run: |
38-
if ${{ contains(github.event.pull_request.labels.*.name, 'ci/no-release') }}; then
38+
if gh pr list --state=merged --search="${GITHUB_SHA}" --label=ci/no-release \
39+
--json=mergeCommit --jq=".[].mergeCommit.oid" | grep -q "${GITHUB_SHA}";
40+
then
3941
echo "The PR has ci/no-release label - skipping the release"
4042
echo "### Skipped release due to ci/no-release label" >> ${GITHUB_STEP_SUMMARY}
4143
exit 0

0 commit comments

Comments
 (0)