Node.js CI and Deploy #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Node.js CI and Deploy | |
on: | |
push: | |
branches: | |
- tmp | |
workflow_dispatch: | |
jobs: | |
build-and-deploy: | |
strategy: | |
matrix: | |
node-version: [20.x] | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install dependencies | |
working-directory: ./strawberry | |
run: npm ci | |
- name: check current directory | |
working-directory: ./strawberry | |
run: | | |
pwd | |
- name: Build | |
working-directory: ./strawberry | |
run: npm run build | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
role-to-assume: ${{ secrets.AWS_ROLE }} | |
aws-region: ${{ secrets.DEFAULT_AWS_REGION }} | |
- name: Deploy to S3 | |
run: aws s3 sync build/ s3://${{ secrets.AWS_S3_BUCKET }} --delete | |
- name: Invalidate CloudFront | |
run: | | |
aws cloudfront create-invalidation \ | |
--distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} \ | |
--paths “/*” |