This is a simple CI/CD config for Github Actions. Hopefully it saves you some time.
It runs npm run build
, then overwrites a folder in a s3 bucket with the local dist
folder.
I have not thoroughly tested the module cache system (.npm
instead of node_modules
).
This guide is licensed under CC0 (public domain).
- Add
.github/workflows/deploy-to-s3.yml
to your repo
- Update
BUCKETNAMEHERE
,DIRNAMEHERE
, andAWS_REGION
.
- Create a new IAM user with programmatic access and a standalone
deploy-s3-IAM-policy.json
- For safety, make a new user for every repo
- Update
BUCKETNAMEHERE
andDIRNAMEHERE
- Add key env vars to Github Secrets (under repo settings)
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
- Push
master
branch of repo
You should then direct Cloudwatch to serve bucket/folder/index.html
.
Set up job
3s
Build jakejarvis/s3-sync-action@c33d061a8f4bddd78d8b5f9f4e5d2fd40a556980
37s
Run actions/checkout@v1
2s
Run actions/setup-node@v1
6s
Run actions/cache@v1
1s
Run npm install
20s
Run npm run build
36s
Run jakejarvis/s3-sync-action@c33d061a8f4bddd78d8b5f9f4e5d2fd40a556980
4s
upload: dist/test.4403abcb.js to s3://BUCKETNAMEHERE/FOLDERNAMEHERE/test.4403abcb.js
Run jakejarvis/s3-sync-action@c33d061a8f4bddd78d8b5f9f4e5d2fd40a556980
/usr/bin/docker run ...
upload: dist/index.html to s3://BUCKETNAMEHERE/FOLDERNAMEHERE/index.html
upload: dist/test.4403abcb.js to s3://BUCKETNAMEHERE/FOLDERNAMEHERE/test.4403abcb.js
Post actions/cache@v1
1s
Complete job
0s