Skip to content

Update docker-deploy-prod.yml #10

Update docker-deploy-prod.yml

Update docker-deploy-prod.yml #10

name: Deploy Staging
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: '16.11.1'
# Cache action set to cache npm installed modules when package-lock or OS changes, otherwise will restore the cache
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Dependencies
run: npm install
- name: Build
run: |
npm run build
- name: Move Build to tmp
run: |
mkdir -p /tmp/workspace/build
mv -v build/* /tmp/workspace/build
- name: Temporarily save Build to artifacts
uses: actions/upload-artifact@v2
with:
name: build-client
path: /tmp/workspace
deploy-staging:
needs: build
runs-on: ubuntu-latest
environment: staging
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.STAGE_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.STAGE_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Retrieve saved Build
uses: actions/download-artifact@v2
with:
name: build-client
path: /tmp/workspace
- name: Deploy to S3
run: aws s3 sync /tmp/workspace/build/ s3://${{ secrets.STAGE_S3_URL }}
- name: Run CF invalidation
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.STAGE_CF_ID }} --paths '/*'