Skip to content

Commit 940cdc8

Browse files
authored
ci: allow ci action run on release branches (#31)
## Description <!-- Provide a brief description of your changes --> **Note:** PR titles should follow [Conventional Commits](https://www.conventionalcommits.org/) format (e.g., `feat(devbox): add support for custom env vars` or `fix(snapshot): resolve pagination issue`) as they are used for automatic release notes generation. ## Type of Change <!-- Mark the relevant option with an 'x' --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update - [ ] Code refactoring - [ ] Performance improvement - [ ] Test updates ## Related Issues <!-- Link to related issues using #issue-number --> Closes # ## Changes Made <!-- Describe the changes in detail --> ## Testing <!-- Describe how you tested your changes --> - [ ] I have tested locally - [ ] I have added/updated tests - [ ] All existing tests pass ## Checklist - [ ] My code follows the code style of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have updated the documentation accordingly - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published ## Screenshots (if applicable) <!-- Add screenshots to help explain your changes --> ## Additional Notes <!-- Any additional information that reviewers should know -->
1 parent a6d91c5 commit 940cdc8

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,24 @@ name: CI
22

33
on:
44
pull_request:
5+
pull_request_target:
6+
# Run on release-please PRs (created by GITHUB_TOKEN which doesn't trigger regular pull_request)
7+
types: [opened, synchronize, reopened]
58
workflow_dispatch:
69

710
jobs:
811
format:
912
runs-on: ubuntu-latest
13+
# Only run from pull_request_target if it's a release-please branch, otherwise skip (to avoid duplicate runs)
14+
if: github.event_name == 'pull_request' || (github.event_name == 'pull_request_target' && startsWith(github.event.pull_request.head.ref, 'release-please--')) || github.event_name == 'workflow_dispatch'
1015
steps:
1116
- name: Checkout code
1217
uses: actions/checkout@v4
18+
with:
19+
# For pull_request_target, explicitly checkout the PR head
20+
ref: ${{ github.event.pull_request.head.sha }}
21+
# Only checkout PR code if it's from the same repo (safe for release-please)
22+
repository: ${{ github.event.pull_request.head.repo.full_name }}
1323

1424
- name: Setup Node.js
1525
uses: actions/setup-node@v4
@@ -25,9 +35,16 @@ jobs:
2535

2636
lint:
2737
runs-on: ubuntu-latest
38+
# Only run from pull_request_target if it's a release-please branch, otherwise skip (to avoid duplicate runs)
39+
if: github.event_name == 'pull_request' || (github.event_name == 'pull_request_target' && startsWith(github.event.pull_request.head.ref, 'release-please--')) || github.event_name == 'workflow_dispatch'
2840
steps:
2941
- name: Checkout code
3042
uses: actions/checkout@v4
43+
with:
44+
# For pull_request_target, explicitly checkout the PR head
45+
ref: ${{ github.event.pull_request.head.sha }}
46+
# Only checkout PR code if it's from the same repo (safe for release-please)
47+
repository: ${{ github.event.pull_request.head.repo.full_name }}
3148

3249
- name: Setup Node.js
3350
uses: actions/setup-node@v4
@@ -43,9 +60,16 @@ jobs:
4360

4461
build:
4562
runs-on: ubuntu-latest
63+
# Only run from pull_request_target if it's a release-please branch, otherwise skip (to avoid duplicate runs)
64+
if: github.event_name == 'pull_request' || (github.event_name == 'pull_request_target' && startsWith(github.event.pull_request.head.ref, 'release-please--')) || github.event_name == 'workflow_dispatch'
4665
steps:
4766
- name: Checkout code
4867
uses: actions/checkout@v4
68+
with:
69+
# For pull_request_target, explicitly checkout the PR head
70+
ref: ${{ github.event.pull_request.head.sha }}
71+
# Only checkout PR code if it's from the same repo (safe for release-please)
72+
repository: ${{ github.event.pull_request.head.repo.full_name }}
4973

5074
- name: Setup Node.js
5175
uses: actions/setup-node@v4
@@ -62,9 +86,16 @@ jobs:
6286
test:
6387
runs-on: ubuntu-latest
6488
needs: build
89+
# Only run from pull_request_target if it's a release-please branch, otherwise skip (to avoid duplicate runs)
90+
if: github.event_name == 'pull_request' || (github.event_name == 'pull_request_target' && startsWith(github.event.pull_request.head.ref, 'release-please--')) || github.event_name == 'workflow_dispatch'
6591
steps:
6692
- name: Checkout code
6793
uses: actions/checkout@v4
94+
with:
95+
# For pull_request_target, explicitly checkout the PR head
96+
ref: ${{ github.event.pull_request.head.sha }}
97+
# Only checkout PR code if it's from the same repo (safe for release-please)
98+
repository: ${{ github.event.pull_request.head.repo.full_name }}
6899

69100
- name: Setup Node.js
70101
uses: actions/setup-node@v4
@@ -89,7 +120,8 @@ jobs:
89120
ready-to-merge:
90121
runs-on: ubuntu-latest
91122
needs: [format, lint, build, test]
92-
if: always()
123+
# Only run from pull_request_target if it's a release-please branch, otherwise skip (to avoid duplicate runs)
124+
if: always() && (github.event_name == 'pull_request' || (github.event_name == 'pull_request_target' && startsWith(github.event.pull_request.head.ref, 'release-please--')) || github.event_name == 'workflow_dispatch')
93125
steps:
94126
- name: Check all jobs passed
95127
run: |

0 commit comments

Comments
 (0)