-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (69 loc) · 2.2 KB
/
main.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
name: CI/CD Pipeline
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20' # Specify your Node.js version
- name: Debug Print working directory
run: pwd
- name: Debug List files
run: ls -al
- name: Install backend dependencies
run: |
cd cdk
npm install
- name: Synthesize CDK
run: |
cd cdk
export FRONTEND_STACK_EXPORTS_AVAILABLE=false
npx cdk synth
- name: Deploy BackendStack
run: |
cd cdk
npx cdk deploy BackendStack --require-approval never
- name: Get API Gateway URL
id: get-url
run: |
api_url=$(aws cloudformation list-exports --query "Exports[?Name=='ApiGateway'].Value" --output text)
echo "API_URL=${api_url}" >> $GITHUB_ENV
echo "REACT_APP_API_GATEWAY_URL=${api_url}" > frontend/.env
- name: Print .env file contents
run: |
cd frontend
cat .env
- name: Install frontend dependencies
run: |
cd frontend
npm install
- name: Build frontend
run: |
cd frontend
export BUILD_PATH=../cdk/resources/build
npx react-scripts build
- name: Deploy FrontendStack
run: |
cd cdk
npx cdk deploy FrontendStack --require-approval never
- name: Deploy BackendStack with exports available
run: |
cd cdk
export FRONTEND_STACK_EXPORTS_AVAILABLE=true
npx cdk deploy BackendStack --require-approval never
- name: Get DeploymentURL
id: get-deployment-url
run: |
deployment_url=$(aws cloudformation list-exports --query "Exports[?Name=='CloudfrontURL'].Value" --output text)
echo "Access the deployment at: ${deployment_url}"