-
Notifications
You must be signed in to change notification settings - Fork 14
118 lines (105 loc) · 3.53 KB
/
ci_cd.yaml
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
107
108
109
110
111
112
113
114
115
116
117
118
name: ci_cd
on:
push:
branches:
- master
pull_request:
branches:
- master
env:
TURBO_CACHE_DIR: .turbo
jobs:
ci:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout ${{ github.sha }}
uses: actions/checkout@v4
- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'
registry-url: https://registry.npmjs.org/
- name: Install NPM dependencies
run: npm ci
- name: Lint
run: npm run lint --if-present
- name: Build
run: npm run build --if-present
- name: Test
run: npm run test --if-present
- name: Get all apps
id: get_apps
run: |
APPS=$(ls -d apps/*/ | cut -d'/' -f2 | jq -R -s -c 'split("\n")[:-1]')
echo "apps=$APPS" >> $GITHUB_OUTPUT
outputs:
apps: ${{ steps.get_apps.outputs.apps }}
cd:
needs: ci
if: ${{ github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
app: ${{ fromJson(needs.ci.outputs.apps) }}
concurrency:
group: cd_${{ matrix.app }}
timeout-minutes: 20
steps:
- name: Checkout ${{ github.sha }}
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org/
- name: Get app dependency paths
id: get_paths
run: |
npm install --global turbo
PATHS=$(node .github/workflows/get-app-paths.js ${{ matrix.app }})
echo "paths=$PATHS" >> $GITHUB_OUTPUT
- name: Check if app needs deployment
id: check_deployment
uses: fkirc/skip-duplicate-actions@v5
with:
paths: ${{ steps.get_paths.outputs.paths }}
paths_ignore: '["**/README.md"]'
- name: Skip deployment
if: steps.check_deployment.outputs.should_skip == 'true'
run: |
echo "Skipping deployment - no relevant changes detected"
exit 0
- name: Install NPM dependencies
if: steps.check_deployment.outputs.should_skip != 'true'
run: npm ci
- name: Configure infra deployment
if: steps.check_deployment.outputs.should_skip != 'true' && matrix.app == 'infra'
run: |
echo "$INFRA_PULUMI_PASSPHRASE" > apps/infra/passphrase.prod.txt
mkdir -p ~/.aws
echo "$INFRA_AWS_CREDENTIALS" > ~/.aws/credentials
env:
INFRA_PULUMI_PASSPHRASE: ${{ secrets.INFRA_PULUMI_PASSPHRASE }}
INFRA_AWS_CREDENTIALS: ${{ secrets.INFRA_AWS_CREDENTIALS }}
- name: Configure k8s deployment
if: steps.check_deployment.outputs.should_skip != 'true' && matrix.app != 'infra'
run: |
docker login https://sjc.vultrcr.com/bluedot -u dbaa58f3-01f1-4fcc-9c14-93cc28f524e0 -p $VULTR_CONTAINER_REGISTRY_PASSWORD
mkdir -p ~/.kube
echo "$K8S_KUBECONFIG" > ~/.kube/config
env:
K8S_KUBECONFIG: ${{ secrets.K8S_KUBECONFIG }}
VULTR_CONTAINER_REGISTRY_PASSWORD: ${{ secrets.VULTR_CONTAINER_REGISTRY_PASSWORD }}
- name: Deploy
if: steps.check_deployment.outputs.should_skip != 'true'
run: npm run deploy:cd --workspace apps/${{ matrix.app }}