Skip to content

Commit 1c37da5

Browse files
committed
ci: fix ci (riccardoperra#374)
* chore: update README.md * fix: update auth0 logout * ci: fix ci for pr deploy * ci: add prod-deploy.yml
1 parent a64fe41 commit 1c37da5

4 files changed

Lines changed: 412 additions & 120 deletions

File tree

.github/workflows/main.yml

Lines changed: 8 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Main
22

33
on:
4-
pull_request_target:
4+
pull_request:
55
types: [ opened, synchronize, reopened ]
66

77
env:
@@ -147,24 +147,18 @@ jobs:
147147
pnpm --filter='@codeimage/api' typecheck:ci
148148
pnpm --filter='@codeimage/app' typecheck
149149
150-
151-
build-app:
152-
name: Build App and Preview
150+
build-app-dev:
151+
name: Build App and Preview (Dev)
153152
environment: Preview
154153
needs: [ build-packages ]
155154
if: (${{ needs.install.outputs.app-change == 'true' }} || ${{ needs.install.outputs.libs-change == 'true' }})
156155
runs-on: ubuntu-latest
157156

158157
steps:
159-
- name: Checkout
160-
if: ${{ github.event_name != 'pull_request_target' }}
161-
uses: actions/checkout@v2
162-
163158
- name: Checkout PR
164-
if: ${{ github.event_name == 'pull_request_target' }}
165159
uses: actions/checkout@v2
166160
with:
167-
ref: ${{ github.event.pull_request.head.sha }}
161+
ref: "refs/pull/${{ github.event.number }}/merge"
168162
- uses: pnpm/action-setup@v2.2.2
169163
with:
170164
version: 7
@@ -197,7 +191,6 @@ jobs:
197191
pnpm --filter=@codeimage/app build
198192
199193
- uses: amondnet/vercel-action@v19
200-
if: ${{ env.IS_NEXT_BRANCH == 'false' }}
201194
with:
202195
vercel-token: ${{ secrets.VERCEL_TOKEN }} # Required
203196
github-token: ${{ secrets.GITHUB_TOKEN }} #Optional
@@ -206,28 +199,7 @@ jobs:
206199
vercel-org-id: ${{ secrets.VERCEL_ORG_ID}} #Required
207200
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID}} #Required
208201
alias-domains: | #Optional
209-
codeimage-pr-{{PR_NUMBER}}.vercel.app
210-
211-
- name: Build vercel output (Next)
212-
if: ${{ env.IS_NEXT_BRANCH == 'true' }}
213-
run: |
214-
cd apps/codeimage
215-
ls
216-
mkdir -p .vercel/output/static
217-
echo '{"version": 3, "routes": [{ "handle": "filesystem" }, {"check": true, "src": "/(.*)", "dest": "/"}]}' > .vercel/output/config.json
218-
mv dist/** .vercel/output/static
219-
- uses: amondnet/vercel-action@v19
220-
if: ${{ env.IS_NEXT_BRANCH == 'true' }}
221-
with:
222-
vercel-token: ${{ secrets.VERCEL_TOKEN }} # Required
223-
github-token: ${{ secrets.GITHUB_TOKEN }} #Optional
224-
vercel-args: '--prebuilt' #Optional
225-
working-directory: apps/codeimage
226-
vercel-org-id: ${{ secrets.VERCEL_ORG_ID}} #Required
227-
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID}} #Required
228-
alias-domains: | #Optional
229-
codeimage-pr-{{PR_NUMBER}}.vercel.app
230-
next.codeimage.dev
202+
codeimage-ui-pr-{{PR_NUMBER}}.vercel.app
231203
232204
233205
build-highlight-dev:
@@ -238,15 +210,10 @@ jobs:
238210
runs-on: ubuntu-latest
239211

240212
steps:
241-
- name: Checkout
242-
if: ${{ github.event_name != 'pull_request_target' }}
243-
uses: actions/checkout@v2
244-
245213
- name: Checkout PR
246-
if: ${{ github.event_name == 'pull_request_target' }}
247214
uses: actions/checkout@v2
248215
with:
249-
ref: ${{ github.event.pull_request.head.sha }}
216+
ref: "refs/pull/${{ github.event.number }}/merge"
250217
- uses: pnpm/action-setup@v2.2.2
251218
with:
252219
version: 7
@@ -272,7 +239,6 @@ jobs:
272239
pnpm --filter=@codeimage/highlight build:dev
273240
274241
- uses: amondnet/vercel-action@v19
275-
if: ${{ env.IS_NEXT_BRANCH == 'false' }}
276242
with:
277243
vercel-token: ${{ secrets.VERCEL_TOKEN }} # Required
278244
github-token: ${{ secrets.GITHUB_TOKEN }} #Optional
@@ -293,15 +259,10 @@ jobs:
293259
runs-on: ubuntu-latest
294260

295261
steps:
296-
- name: Checkout
297-
if: ${{ github.event_name != 'pull_request_target' }}
298-
uses: actions/checkout@v2
299-
300262
- name: Checkout PR
301-
if: ${{ github.event_name == 'pull_request_target' }}
302263
uses: actions/checkout@v2
303264
with:
304-
ref: ${{ github.event.pull_request.head.sha }}
265+
ref: "refs/pull/${{ github.event.number }}/merge"
305266
- uses: pnpm/action-setup@v2.2.2
306267
with:
307268
version: 7
@@ -327,7 +288,6 @@ jobs:
327288
pnpm --filter=@codeimage/ui build:dev
328289
329290
- uses: amondnet/vercel-action@v19
330-
if: ${{ env.IS_NEXT_BRANCH == 'false' }}
331291
with:
332292
vercel-token: ${{ secrets.VERCEL_TOKEN }} # Required
333293
github-token: ${{ secrets.GITHUB_TOKEN }} #Optional
@@ -367,7 +327,6 @@ jobs:
367327
- name: Build
368328
run: |
369329
pnpm --filter=@codeimage/api build:ts
370-
pnpm prepare:api:deploy
371330
372331
- name: Cache build
373332
uses: actions/cache@v3
@@ -389,6 +348,7 @@ jobs:
389348
env:
390349
POSTGRES_USER: postgres
391350
POSTGRES_PASSWORD: postgres
351+
POSTGRES_DB: test_codeimage
392352
options: >-
393353
--health-cmd pg_isready
394354
--health-interval 10s
@@ -409,7 +369,6 @@ jobs:
409369
MOCK_AUTH_EMAIL: dev@example.it
410370
ALLOWED_ORIGINS: "*"
411371

412-
413372
steps:
414373
- uses: actions/checkout@v2
415374
- uses: pnpm/action-setup@v2.2.2
@@ -441,74 +400,6 @@ jobs:
441400
- name: Test
442401
run: pnpm --filter=@codeimage/api test:ci
443402

444-
deploy-next:
445-
# Next branch only
446-
if: ${{ github.head_ref == 'next' }}
447-
environment: Next
448-
name: Deploy next
449-
needs: [
450-
lint,
451-
build-packages,
452-
build-api,
453-
typecheck-packages,
454-
be-test
455-
]
456-
runs-on: ubuntu-latest
457-
steps:
458-
- uses: actions/checkout@v2
459-
- uses: pnpm/action-setup@v2.2.2
460-
with:
461-
version: 7
462-
- name: Use Node.js ${{ matrix.node-version }}
463-
uses: actions/setup-node@v2
464-
with:
465-
node-version: ${{ matrix.node-version }}
466-
cache: 'pnpm'
467-
468-
- name: Install dependencies
469-
run: pnpm install
470-
471-
- name: Restore api build
472-
uses: actions/cache@v3
473-
with:
474-
path: |
475-
dist/api-bundle/**
476-
key: rest-api-bundle-${{ github.run_id }}-${{ github.run_number }}
477-
478-
- name: Install Railway
479-
run: pnpm i -g @railway/cli
480-
481-
- name: Run migrations
482-
run: |
483-
cd apps/api
484-
pnpm exec prisma migrate deploy
485-
env:
486-
DATABASE_URL: ${{ secrets.NEXT_DATABASE_URL }}
487-
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
488-
489-
- name: Deploy
490-
run: |
491-
cd dist/api-bundle
492-
rm -rf .gitignore
493-
touch .gitignore
494-
touch .dockerignore
495-
ls -al
496-
railway up
497-
env:
498-
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
499-
500-
# deploy-prod:
501-
# # Production branch only
502-
# if: github.ref == 'refs/heads/main'
503-
# environment: Production
504-
# name: Deploy prod
505-
# needs: [ lint, build-app, build-api, typecheck-packages, typecheck-app, be-test ]
506-
# runs-on: ubuntu-latest
507-
# steps:
508-
# - uses: actions/checkout@v2
509-
# - name: Execute tests
510-
# run: exit 0
511-
512403
concurrency:
513404
group: main-${{ github.head_ref }}
514405
cancel-in-progress: true

0 commit comments

Comments
 (0)