Skip to content

Commit 31fddc7

Browse files
committed
fix(ci): prevent automatic canary releases on non-main branches
1 parent 275fcfd commit 31fddc7

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

.github/workflows/build.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,36 @@
11
name: build
2-
on: [push]
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
types: [labeled, synchronize]
37

48
permissions:
59
contents: write # Create releases and tags
610
pull-requests: write # Comment on PRs with release info
711
packages: write # Publish to GitHub Packages
812

13+
concurrency:
14+
group: release-${{ github.event.pull_request.number || github.ref }}
15+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
16+
917
jobs:
1018
build-linting:
19+
if: github.event_name == 'push'
1120
uses: ./.github/workflows/linting.yml
1221

1322
release:
1423
needs: [build-linting]
1524
runs-on: ubuntu-latest
16-
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
25+
if: >-
26+
!failure() && !cancelled() &&
27+
((github.event_name == 'push'
28+
&& !contains(github.event.head_commit.message, 'ci skip')
29+
&& !contains(github.event.head_commit.message, 'skip ci'))
30+
|| (github.event_name == 'pull_request'
31+
&& ((github.event.action == 'labeled' && github.event.label.name == 'canary')
32+
|| (github.event.action == 'synchronize'
33+
&& contains(github.event.pull_request.labels.*.name, 'canary')))))
1734
steps:
1835
- name: Checkout repository
1936
uses: actions/checkout@v6

0 commit comments

Comments
 (0)