Skip to content

Instantly share code, notes, and snippets.

@mathisve
Created December 2, 2021 15:24
Show Gist options
  • Save mathisve/d27c1a0e2cfbad5012abc1a7957c81eb to your computer and use it in GitHub Desktop.
Save mathisve/d27c1a0e2cfbad5012abc1a7957c81eb to your computer and use it in GitHub Desktop.
react s3 cloudfront CI
name: React publish
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Build React
run: |
cd website
npm ci
npm run build
npm test
- name: Install AWS CLI
uses: unfor19/install-aws-cli-action@v1
with:
version: 2
verbose: true
- name: Set Config
run: |
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} --profile default
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} --profile default
aws configure set region eu-central-1 --profile default
- name: S3 Sync
run: |
aws s3 sync website/build/ s3://${{ secrets.AWS_S3_BUCKET }} --delete
- name: Invalidate Cloudfront
run: |
aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_ID }} --paths "/*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment