Skip to content

Commit 26540db

Browse files
committed
Use pull_request instead and check if secret is set
1 parent 312e20c commit 26540db

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

.github/workflows/deploy.yml

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ on:
33
push:
44
branches:
55
- main
6-
pull_request_target:
6+
pull_request:
77
types: [opened, reopened, synchronize, closed]
88

99
concurrency:
10-
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
10+
group: ${{ github.workflow }}-${{ github.ref }}
1111
cancel-in-progress: true
1212

1313
permissions:
@@ -25,9 +25,6 @@ jobs:
2525
steps:
2626
- name: ⬇️ Checkout repo
2727
uses: actions/checkout@v4
28-
with:
29-
ref: ${{ github.event.pull_request.head.sha || github.sha }}
30-
3128
- name: ⎔ Setup node
3229
uses: actions/setup-node@v4
3330
with:
@@ -51,9 +48,6 @@ jobs:
5148
steps:
5249
- name: ⬇️ Checkout repo
5350
uses: actions/checkout@v4
54-
with:
55-
ref: ${{ github.event.pull_request.head.sha || github.sha }}
56-
5751
- name: ⎔ Setup node
5852
uses: actions/setup-node@v4
5953
with:
@@ -80,9 +74,6 @@ jobs:
8074
steps:
8175
- name: ⬇️ Checkout repo
8276
uses: actions/checkout@v4
83-
with:
84-
ref: ${{ github.event.pull_request.head.sha || github.sha }}
85-
8677
- name: ⎔ Setup node
8778
uses: actions/setup-node@v4
8879
with:
@@ -107,9 +98,6 @@ jobs:
10798
steps:
10899
- name: ⬇️ Checkout repo
109100
uses: actions/checkout@v4
110-
with:
111-
ref: ${{ github.event.pull_request.head.sha || github.sha }}
112-
113101
- name: 🏄 Copy test env vars
114102
run: cp .env.example .env
115103

@@ -188,7 +176,7 @@ jobs:
188176
deploy-staging:
189177
name: 🚁 Deploy staging app for PR
190178
runs-on: ubuntu-24.04
191-
if: ${{ github.event_name == 'pull_request_target' }}
179+
if: ${{ github.event_name == 'pull_request' && secrets.FLY_API_TOKEN }}
192180
outputs:
193181
url: ${{ steps.deploy.outputs.url }}
194182
environment:
@@ -199,8 +187,6 @@ jobs:
199187
uses: actions/checkout@v4
200188
with:
201189
fetch-depth: '50'
202-
ref: ${{ github.event.pull_request.head.sha }}
203-
204190
- name: 👀 Read app name
205191
uses: SebRollen/[email protected]
206192
id: app_name
@@ -211,7 +197,7 @@ jobs:
211197
- name: 🎈 Setup Fly
212198
uses: superfly/flyctl-actions/[email protected]
213199

214-
- name: 🏗️ Create Fly app and provision resources
200+
- name: 🚁️ Deploy PR app to Fly.io
215201
if: github.event.action != 'closed'
216202
run: |
217203
FLY_APP_NAME="${{ steps.app_name.outputs.value }}-pr-${{ github.event.number }}"
@@ -227,7 +213,16 @@ jobs:
227213
flyctl storage create --app $FLY_APP_NAME --name epic-stack-$FLY_APP_NAME --yes > /dev/null 2>&1
228214
fi
229215
230-
flyctl deploy . --ha=false --regions $FLY_REGION --vm-size shared-cpu-1x --env APP_ENV=staging --env ALLOW_INDEXING=false --app $FLY_APP_NAME --image-label ${{ github.sha }} --build-arg COMMIT_SHA=${{ github.sha }} --build-secret SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
216+
flyctl deploy . \
217+
--ha=false \ # use only one machine for staging
218+
--regions $FLY_REGION \
219+
--vm-size shared-cpu-1x \
220+
--env APP_ENV=staging \
221+
--env ALLOW_INDEXING=false \
222+
--app $FLY_APP_NAME \
223+
--image-label ${{ github.sha }} \
224+
--build-arg COMMIT_SHA=${{ github.sha }} \
225+
--build-secret SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
231226
232227
- name: 🧹 Cleanup resources when PR is closed
233228
if: github.event.action == 'closed'

0 commit comments

Comments
 (0)