-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (119 loc) · 4.02 KB
/
cicd.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: CICD
env:
VITE_PUBLIC_URL: ""
VITE_BASE_URL: ""
permissions:
id-token: write
contents: read
on:
pull_request:
types: [opened, synchronize]
push:
workflow_dispatch:
jobs:
client:
runs-on: ubuntu-latest
defaults:
run:
working-directory: client
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/cache@v3
with:
path: .npm
key: npm-client-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-client-
- run: npm ci --prefer-offline --no-audit --no-optional
- run: npm run lint
- run: npm run prettier
- run: npm run build
server:
runs-on: ubuntu-latest
defaults:
run:
working-directory: server
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/cache@v3
with:
path: .npm
key: npm-server-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-server-
- run: npm ci --prefer-offline --no-audit --no-optional
- run: npm run lint
- run: npm run prettier
- run: npm run build
# deploy:
# needs: [client, server]
# if: github.repository_owner == 'PropertyPraxis' && github.ref == 'refs/heads/production' && github.event_name == 'push'
# runs-on: ubuntu-latest
# env:
# DEPLOY_ENV: ${{ github.ref == 'refs/heads/production' && 'prod' || 'prod' }}
# steps:
# - uses: actions/checkout@v4
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/ptap-terraform-github-role
# aws-region: us-east-1
# - uses: actions/setup-node@v4
# with:
# node-version: 20
# - uses: actions/cache@v3
# working-directory: client
# with:
# path: .npm
# key: npm-client-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# npm-client-
# - name: Build assets for ${{ env.DEPLOY_ENV }}
# working-directory: client
# env:
# S3_BUCKET: property-praxis-${{ env.DEPLOY_ENV }}-assets
# VITE_PUBLIC_URL: https://propertypraxis.com
# VITE_BASE_URL: ""
# run: |
# npm ci --prefer-offline --no-audit --no-optional
# npm run build
# - env:
# S3_BUCKET: property-praxis-${{ env.DEPLOY_ENV }}-assets
# working-directory: client
# run: aws s3 cp ./dist/ s3://$S3_BUCKET/ --cache-control no-cache --recursive
# - name: Login to Amazon ECR
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v2
# - name: Check if ECR image exists
# id: container-exists
# continue-on-error: true
# env:
# REPOSITORY: property-praxis-${{ env.DEPLOY_ENV }}
# IMAGE_TAG: ${{ env.DEPLOY_ENV }}-${{ github.sha }}
# run: aws ecr describe-images --repository-name=$REPOSITORY --image-ids=imageTag=$IMAGE_TAG
# - name: Build, tag, and push docker image to ECR
# if: steps.container-exists.outcome != 'success'
# working-directory: server
# env:
# REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# REPOSITORY: property-praxis-${{ env.DEPLOY_ENV }}
# IMAGE_TAG: ${{ env.DEPLOY_ENV }}-${{ github.sha }}
# run: |
# docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
# docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
# - uses: hashicorp/setup-terraform@v2
# with:
# terraform_version: 1.1.7
# - name: Update Lambda with Terraform
# working-directory: ./tf/${{ env.DEPLOY_ENV }}
# env:
# TF_VAR_lambda_image_tag: ${{ env.DEPLOY_ENV }}-${{ github.sha }}
# run: |
# terraform init
# terraform apply -auto-approve