Skip to content

Commit 3cb8e95

Browse files
committed
feat: S3 upload
1 parent 7edb84e commit 3cb8e95

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

.github/workflows/node.js.yml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
22
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
33

4-
name: Node.js CI
4+
name: Node.js CI and Deploy
55

66
on:
77
push:
@@ -29,26 +29,35 @@ jobs:
2929
- run: yarn build
3030
# - run: yarn test
3131
- name: Upload distribution artifacts
32-
uses: actions/upload-pages-artifact@v3
32+
uses: actions/upload-artifact@v4
3333
with:
34-
name: github-pages
34+
name: build-artifacts
3535
path: dist
3636

3737
deploy:
3838
runs-on: ubuntu-latest
3939
needs: build
40-
41-
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
42-
permissions:
43-
pages: write # to deploy to Pages
44-
id-token: write # to verify the deployment originates from an appropriate source
45-
46-
# Deploy to the github-pages environment
47-
environment:
48-
name: github-pages
49-
url: ${{ steps.deployment.outputs.page_url }}
40+
if: github.ref == 'refs/heads/main' # Only deploy on main branch
5041

5142
steps:
52-
- name: Deploy to GitHub Pages
53-
id: deployment
54-
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action
43+
- uses: actions/checkout@v4
44+
- name: Download build artifacts
45+
uses: actions/download-artifact@v4
46+
with:
47+
name: build-artifacts
48+
path: dist
49+
50+
- name: Configure AWS credentials
51+
uses: aws-actions/configure-aws-credentials@v4
52+
with:
53+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
54+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
55+
aws-region: ${{ secrets.AWS_REGION }}
56+
57+
- name: Deploy to S3
58+
run: |
59+
aws s3 sync dist/ s3://${{ secrets.S3_BUCKET }}
60+
61+
# - name: Invalidate CloudFront cache
62+
# run: |
63+
# aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*"

0 commit comments

Comments
 (0)