-
Notifications
You must be signed in to change notification settings - Fork 3
107 lines (89 loc) · 3.37 KB
/
Copy pathfrontend-deploy.yml
File metadata and controls
107 lines (89 loc) · 3.37 KB
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
name: Deploy React to S3 + CloudFront
on:
push:
branches: [ develop ]
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
env:
FRONTEND_DIR: "."
BUILD_DIR: "dist"
S3_BUCKET_MAIN: "pooli-frontend-prod"
S3_BUCKET_OFFICE: "pooli-frontend-office-prod"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22.20.0
cache: npm
cache-dependency-path: ${{ env.FRONTEND_DIR }}/package-lock.json
- name: Install dependencies
working-directory: ${{ env.FRONTEND_DIR }}
run: npm ci
- name: Build
working-directory: ${{ env.FRONTEND_DIR }}
run: npm run build
- name: Inspect build output (debug)
working-directory: ${{ env.FRONTEND_DIR }}
run: |
set -euo pipefail
echo "== Build dir listing =="
ls -al "${BUILD_DIR}"
echo "== index.html (first 30 lines) =="
sed -n '1,30p' "${BUILD_DIR}/index.html"
echo "== index.html sha256 =="
sha256sum "${BUILD_DIR}/index.html"
- name: Configure AWS credentials (OIDC)
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Head S3 index.html before deploy (main)
run: |
set -euo pipefail
aws s3api head-object --bucket "${S3_BUCKET_MAIN}" --key "index.html" \
|| echo "main bucket: index.html not found yet"
- name: Head S3 index.html before deploy (office)
run: |
set -euo pipefail
aws s3api head-object --bucket "${S3_BUCKET_OFFICE}" --key "index.html" \
|| echo "office bucket: index.html not found yet"
- name: Deploy to S3 (main)
working-directory: ${{ env.FRONTEND_DIR }}
run: |
set -euo pipefail
aws s3 sync "${BUILD_DIR}/" "s3://${S3_BUCKET_MAIN}" --delete --exact-timestamps
echo "== Main bucket top-level listing =="
aws s3 ls "s3://${S3_BUCKET_MAIN}/" | head -n 50
- name: Deploy to S3 (office)
working-directory: ${{ env.FRONTEND_DIR }}
run: |
set -euo pipefail
aws s3 sync "${BUILD_DIR}/" "s3://${S3_BUCKET_OFFICE}" --delete --exact-timestamps
echo "== Office bucket top-level listing =="
aws s3 ls "s3://${S3_BUCKET_OFFICE}/" | head -n 50
- name: Head S3 index.html after deploy (main)
run: |
set -euo pipefail
aws s3api head-object --bucket "${S3_BUCKET_MAIN}" --key "index.html"
- name: Head S3 index.html after deploy (office)
run: |
set -euo pipefail
aws s3api head-object --bucket "${S3_BUCKET_OFFICE}" --key "index.html"
- name: CloudFront Cache Invalidation (main)
run: |
set -euo pipefail
aws cloudfront create-invalidation \
--distribution-id "${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}" \
--paths "/index.html"
- name: CloudFront Cache Invalidation (office)
run: |
set -euo pipefail
aws cloudfront create-invalidation \
--distribution-id "${{ secrets.CLOUDFRONT_OFFICE_DISTRIBUTION_ID }}" \
--paths "/index.html"