Last active
June 1, 2020 19:44
-
-
Save callmeloureiro/08d98b44ddd416c3493036f83df9b50a to your computer and use it in GitHub Desktop.
CI/CD - on push master
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: CI/CD - Master | |
on: | |
push: | |
branches: | |
- master | |
env: | |
AWS_BUCKET_NAME: <BUCKET_NAME> | |
AWS_REGION: <REGION> | |
AWS_ACCESS_KEY_ID: <ACCESS_KEY_ID> | |
AWS_SECRET_ACCESS_KEY: <SECRET_ACCESS_KEY> | |
BUILD_FOLDER: <FOLDER_NAME> | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: "12.x" | |
- name: Install | |
run: | | |
yarn install | |
- name: Build | |
run: | | |
yarn build | |
env: | |
CI: false | |
- name: Share artifact inside workflow | |
uses: actions/upload-artifact@v1 | |
with: | |
name: ${{ env.BUILD_FOLDER }} | |
path: ${{ env.BUILD_FOLDER }} | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Get artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: ${{ env.BUILD_FOLDER }} | |
path: ${{ env.BUILD_FOLDER }} | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Deploy to S3 | |
run: aws s3 sync . s3://${{ env.AWS_BUCKET_NAME }} --acl public-read --delete | |
working-directory: ${{ env.BUILD_FOLDER }} | |
cleanup: | |
runs-on: ubuntu-latest | |
needs: deploy | |
steps: | |
- name: Delete artifact | |
uses: geekyeggo/delete-artifact@v1 | |
with: | |
name: ${{ env.BUILD_FOLDER }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment