-
Notifications
You must be signed in to change notification settings - Fork 2
106 lines (88 loc) · 2.89 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Build and preview the project
on:
pull_request:
branches: [ main ]
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.run_id }}"
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
env:
NODE_ENV: test
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test
MYSQL_PORT: 3306
DATABASE_URL: mysql://root:[email protected]:3306/test
CONVERTKIT_API_KEY: api_key
CONVERTKIT_FORM_ID: form_id
steps:
- uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/install-dependencies
- name: Lint the projects
run: yarn lint
- name: Build the projects
run: yarn build
- name: Start MySQL server
run: sudo systemctl start mysql.service
- name: Run tests
run: |
yarn prisma migrate dev --schema=packages/domain/prisma/schema.prisma
yarn test -- --runInBand --coverage
should-preview-frontend:
runs-on: ubuntu-latest
environment: 'Preview'
needs:
- build
outputs:
frontendChanged: ${{ steps.frontend-changed.outputs.any_changed }}
steps:
- uses: actions/checkout@v4
- name: Check if frontend files changed
id: frontend-changed
uses: tj-actions/changed-files@v44
with:
files_yaml: |
apps:
- apps/web/**
packages:
- packages/front/**
- name: Run step if test file(s) change
env:
ALL_CHANGED_FILES: ${{ steps.frontend-changed.outputs.all_changed_files }}
run: |
echo "Change state: ${{ steps.frontend-changed.outputs.any_changed }}"
echo "One or more test file(s) has changed."
echo "List all the files that have changed: $ALL_CHANGED_FILES"
preview-frontend:
runs-on: ubuntu-latest
environment: 'Preview'
needs:
- should-preview-frontend
if: ${{ needs.should-preview-frontend.frontendChanged == 'true' }}
steps:
- uses: actions/checkout@v4
- name: Install Yarn 4
run: |
corepack enable
yarn set version 4.2.2
- name: Install Vercel CLI
if: ${{ success() }}
run: npm install --global vercel@latest
- name: Pull Vercel Environment Information
if: ${{ success() }}
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
if: ${{ success() }}
env:
APP_VERSION:
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
if: ${{ success() }}
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}