Skip to content

Commit ad8408a

Browse files
committed
Only run release build when PR has certain label
1 parent 48a7827 commit ad8408a

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

.github/workflows/release.yaml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: Build and release
22

33
on:
44
push:
5-
branches:
6-
- master
75
tags:
86
- 'v*'
97
- 'cabal-install-*'
@@ -14,8 +12,32 @@ on:
1412
- cron: '0 0 * * *'
1513
workflow_dispatch:
1614

15+
env:
16+
BUILD_LABEL: "run release build"
17+
1718
jobs:
19+
check-pr-labels:
20+
name: check PR labels
21+
runs-on: ubuntu-latest
22+
outputs:
23+
run_release_workflow: ${{ steps.gen_output.outputs.apt_tools }}
24+
steps:
25+
- id: gen_output
26+
run: |
27+
if [ "${{ github.event_name }}" = 'pull_request' ] ; then
28+
run_it=$(if gh api --jq '.labels.[].name' /repos/${{ github.repository }}/pulls/${{ github.event.number }} | grep --quiet '^${{ env.BUILD_LABEL }}$' ; then printf "%s" "yes" ; else printf "%s" "no" ; fi)
29+
echo "${run_it}"
30+
echo run_release_workflow="${run_it}" >> "$GITHUB_OUTPUT"
31+
else
32+
echo run_release_workflow="yes" >> "$GITHUB_OUTPUT"
33+
fi
34+
shell: bash
35+
env:
36+
GH_TOKEN: ${{ github.token }}
37+
1838
release-workflow:
39+
needs: ["check-pr-labels"]
40+
if: ${{ needs.check-pr-labels.outputs.run_release_workflow == 'yes' }}
1941
uses: ./.github/workflows/reusable-release.yml
2042
with:
2143
branches: '["${{ github.ref }}"]'

0 commit comments

Comments
 (0)