Skip to content

Commit 1e6c10c

Browse files
Fix and improve master branch check in publish CI workflow
1 parent 6f0525c commit 1e6c10c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

.github/workflows/publish.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,18 @@ jobs:
2323
- uses: actions/checkout@v3
2424
with:
2525
fetch-depth: 0
26-
- name: Fail if not on 'master' branch
27-
if: github.ref != 'refs/heads/master'
26+
- name: Fail if manually triggered workflow is not on 'master' branch
27+
if: github.event_name == 'workflow_dispatch' && github.ref_name != 'master'
28+
run: exit -1
29+
- name: Extract branch name from tag
30+
id: get_branch_name
31+
if: github.ref_type == 'tag'
32+
run: |
33+
export BRANCH_NAME=$(git log -1 --format='%D' $env:GITHUB_REF | | sed -e 's/.*origin\/\(.*\),.*/\1/')
34+
echo ::set-output name=branch_name::${BRANCH_NAME}
35+
shell: bash
36+
- name: Fail if tag is not on 'master' branch
37+
if: github.ref_type == 'tag' && steps.get_branch_name.outputs.branch_name != 'master'
2838
run: exit -1
2939
- name: Set up Python 3.8
3040
uses: actions/setup-python@v4

0 commit comments

Comments
 (0)