Skip to content

Merge pull request #310 from data-mermaid/dependabot/npm_and_yarn/sem… #19

Merge pull request #310 from data-mermaid/dependabot/npm_and_yarn/sem…

Merge pull request #310 from data-mermaid/dependabot/npm_and_yarn/sem… #19

Workflow file for this run

name: Build, Test, and Deploy
on:
push:
branches:
- dev
tags:
- 'v[0-9]+.[0-9]+' # eg: v1.1
- 'v[0-9]+.[0-9]+.[0-9]+' # eg: v1.1.1
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v3
- name: set up node.js
uses: actions/setup-node@v3
with:
node-version: '14.17.6'
- name: install dependencies
run: |
sudo apt-get update
sudo apt-get install awscli python3-requests
npm install
- name: run lint
run: npm run lint
- name: run test
run: npm run test
- name: set dev settings
if: startsWith(github.ref, 'refs/heads/dev')
run: |
echo "AWS_CF_ID=${{ secrets.AWS_CF_ID_DEV }}" >> $GITHUB_ENV
echo "REACT_APP_MERMAID_API_URL=https://dev-api.datamermaid.org" >> $GITHUB_ENV
echo "DASH_URL=dev-dashboard2.datamermaid.org" >> $GITHUB_ENV
- name: set prod settings
if: startsWith(github.ref, 'refs/tags')
run: |
echo "AWS_CF_ID=${{ secrets.AWS_CF_ID_PROD }}" >> $GITHUB_ENV
echo "REACT_APP_MERMAID_API_URL=https://api.datamermaid.org" >> $GITHUB_ENV
echo "DASH_URL=dashboard2.datamermaid.org" >> $GITHUB_ENV
- name: build and deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: 'us-east-1'
run: |
export REACT_APP_MERMAID_API_URL=$REACT_APP_MERMAID_API_URL
npm run build
aws s3 sync build/ s3://$DASH_URL/ --delete
aws cloudfront create-invalidation --distribution-id $AWS_CF_ID --paths "/*"