Last active
March 8, 2022 00:46
-
-
Save Oliver-ke/855c140b77848bb81055b48c645296e2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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: Frontend Cloudfront Deployment | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [12.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: Yarn Install | |
run: yarn install | |
- name: Yarn Build | |
run: yarn build | |
env: | |
REACT_APP_API_URL: ${{ secrets.REACT_APP_API_URL }} | |
- name: Share artifact inside workflow | |
uses: actions/upload-artifact@v1 | |
with: | |
name: build-artifact | |
path: build | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
# get build artifact | |
- name: Get artifact | |
uses: actions/download-artifact@v1 | |
with: | |
name: build-artifact | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | |
# Copy build to s3 | |
- name: Deploy to S3 | |
run: | | |
S3_BUCKET=s3://<s3-bucket-name> | |
aws s3 sync . $S3_BUCKET --acl private | |
working-directory: build-artifact | |
- name: Create Cloudfront Invalidation | |
run: | | |
DISTRIBUTION_ID=<distribution-id> | |
aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths /* | |
working-directory: build-artifact |
secrets to add
AWS_ACCESS_KEY_ID
AWS_DEFAULT_REGION
AWS_SECRET_ACCESS_KEY
REACT_APP_GOOGLE_MAP
REACT_APP_URL
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Get CLI account conical id using
aws s3api list-buckets --query Owner.ID --output text