Skip to content

Commit 82949ad

Browse files
authored
build the container while linting/testing (#996)
1 parent dcd09a2 commit 82949ad

File tree

1 file changed

+58
-13
lines changed

1 file changed

+58
-13
lines changed

.github/workflows/deploy.yml

+58-13
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
uses: bahmutov/npm-install@v1
3232

3333
- name: 🏄 Copy test env vars
34-
run: cp .env.example .env
34+
run: cp .env.example .env
3535

3636
- name: 🛠 Setup Database
3737
run: npx prisma migrate deploy && npx prisma generate --sql
@@ -58,7 +58,7 @@ jobs:
5858
run: npm run build
5959

6060
- name: 🏄 Copy test env vars
61-
run: cp .env.example .env
61+
run: cp .env.example .env
6262

6363
- name: 🛠 Setup Database
6464
run: npx prisma migrate deploy && npx prisma generate --sql
@@ -82,7 +82,7 @@ jobs:
8282
uses: bahmutov/npm-install@v1
8383

8484
- name: 🏄 Copy test env vars
85-
run: cp .env.example .env
85+
run: cp .env.example .env
8686

8787
- name: 🛠 Setup Database
8888
run: npx prisma migrate deploy && npx prisma generate --sql
@@ -143,13 +143,57 @@ jobs:
143143
path: playwright-report/
144144
retention-days: 30
145145

146+
container:
147+
name: 📦 Prepare Container
148+
runs-on: ubuntu-24.04
149+
# only prepare container on pushes
150+
if: ${{ github.event_name == 'push' }}
151+
steps:
152+
- name: ⬇️ Checkout repo
153+
uses: actions/checkout@v4
154+
with:
155+
fetch-depth: 50
156+
157+
- name: 👀 Read app name
158+
uses: SebRollen/[email protected]
159+
id: app_name
160+
with:
161+
file: 'fly.toml'
162+
field: 'app'
163+
164+
- name: 🎈 Setup Fly
165+
uses: superfly/flyctl-actions/[email protected]
166+
167+
- name: 📦 Build Staging Container
168+
if: ${{ github.ref == 'refs/heads/dev' }}
169+
run: |
170+
flyctl deploy \
171+
--build-only \
172+
--push \
173+
--image-label ${{ github.sha }} \
174+
--build-arg COMMIT_SHA=${{ github.sha }} \
175+
--app ${{ steps.app_name.outputs.value }}-staging
176+
env:
177+
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
178+
179+
- name: 📦 Build Production Container
180+
if: ${{ github.ref == 'refs/heads/main' }}
181+
run: |
182+
flyctl deploy \
183+
--build-only \
184+
--push \
185+
--image-label ${{ github.sha }} \
186+
--build-arg COMMIT_SHA=${{ github.sha }} \
187+
--app ${{ steps.app_name.outputs.value }}
188+
env:
189+
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
190+
146191
deploy:
147192
name: 🚀 Deploy
148-
runs-on: ubuntu-22.04
149-
needs: [lint, typecheck, vitest, playwright]
150-
# only build/deploy branches on pushes
193+
runs-on: ubuntu-24.04
194+
needs: [lint, typecheck, vitest, playwright, container]
195+
# only deploy on pushes
151196
if: ${{ github.event_name == 'push' }}
152-
153197
steps:
154198
- name: ⬇️ Checkout repo
155199
uses: actions/checkout@v4
@@ -168,16 +212,17 @@ jobs:
168212

169213
- name: 🚀 Deploy Staging
170214
if: ${{ github.ref == 'refs/heads/dev' }}
171-
run:
172-
flyctl deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }}
173-
--app ${{ steps.app_name.outputs.value }}-staging
215+
run: |
216+
IMAGE="registry.fly.io/${{ steps.app_name.outputs.value }}-staging:${{ github.sha }}"
217+
flyctl deploy --image $IMAGE --app ${{ steps.app_name.outputs.value }}-staging
174218
env:
175219
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
176220

177221
- name: 🚀 Deploy Production
178222
if: ${{ github.ref == 'refs/heads/main' }}
179-
run:
180-
flyctl deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }}
181-
--build-secret SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
223+
run: |
224+
IMAGE="registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.sha }}"
225+
flyctl deploy --image $IMAGE \
226+
--build-secret SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
182227
env:
183228
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

0 commit comments

Comments
 (0)