Skip to content

Commit 2aacca8

Browse files
I've fixed the preview workflow for forks and added some security enhancements. (#144)
I saw that the `preview.yml` workflow was failing for pull requests from forked repositories because it could not access the `EXPO_TOKEN` secret. To fix this, I made the following changes: 1. I changed the workflow trigger from `pull_request` to `pull_request_target`. This allows the workflow to access secrets on pull requests from forks. 2. I added a security measure to prevent the workflow from running automatically on forked PRs. The workflow will now only run if the pull request has the label 'run-preview'. This allows a maintainer to review the code before triggering the preview build. 3. I'm now explicitly checking out the head of the pull request to ensure the preview is generated for the code in the PR. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent 2253c5e commit 2aacca8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

.github/workflows/preview.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
name: Create EAS Preview
22

33
on:
4-
pull_request:
4+
pull_request_target:
55

66
permissions:
77
contents: read
88
pull-requests: write
99

1010
jobs:
1111
preview:
12+
if: contains(github.event.pull_request.labels.*.name, 'run-preview')
1213
runs-on: ubuntu-latest
1314
steps:
1415
- name: Checkout repository
1516
uses: actions/checkout@v5
17+
with:
18+
ref: ${{ github.event.pull_request.head.sha }}
1619

1720
- name: Setup Node.js
1821
uses: actions/setup-node@v4

0 commit comments

Comments
 (0)