Skip to content

Commit 63950ba

Browse files
committed
Add github action to deploy to AWS S3 bucket
1 parent db9302e commit 63950ba

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

.github/workflows/cdn-deploy.yml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Deploy to CDN
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
name: Build
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Setup node
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: 20
20+
cache: yarn
21+
env:
22+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
23+
24+
- name: Increase network timeout
25+
run: yarn config set network-timeout 300000
26+
env:
27+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
28+
29+
- name: Install dependencies
30+
run: yarn install --prefer-offline
31+
env:
32+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
33+
34+
- name: Build
35+
continue-on-error: false
36+
run: yarn build
37+
env:
38+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
39+
40+
- name: Upload artifact
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: dist
44+
path: dist
45+
retention-days: 30
46+
47+
deploy:
48+
name: Deploy
49+
needs: build
50+
runs-on: ubuntu-latest
51+
permissions:
52+
id-token: write
53+
contents: read
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v4
57+
58+
- name: Download artifact
59+
uses: actions/download-artifact@v4
60+
with:
61+
name: dist
62+
path: dist
63+
64+
- name: Configure AWS credentials
65+
uses: aws-actions/configure-aws-credentials@v4
66+
with:
67+
role-to-assume: ${{ secrets.AWS_GITHUB_ACTION_ROLE }}
68+
aws-region: us-east-2
69+
70+
- name: Sync files to S3 bucket
71+
run: |
72+
aws s3 sync dist s3://cdn.zigurous.com --delete

0 commit comments

Comments
 (0)