Skip to content

Merge pull request #712 from NASA-IMPACT/develop #90

Merge pull request #712 from NASA-IMPACT/develop

Merge pull request #712 from NASA-IMPACT/develop #90

name: Deploy to production
on:
push:
branches:
- production
workflow_dispatch: # Support manual deployments, https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: production
env:
ADMG_ACCESS_TOKEN: ${{ secrets.ADMG_ACCESS_TOKEN }}
GATSBY_ADMG_CLIENT_ID: ${{ secrets.GATSBY_ADMG_CLIENT_ID }}
GATSBY_ADMG_CLIENT_SECRET: ${{ secrets.GATSBY_ADMG_CLIENT_SECRET }}
GATSBY_CPU_COUNT: 2
GATSBY_MAPBOX_TOKEN: ${{ secrets.GATSBY_MAPBOX_TOKEN }}
GA_MEASUREMENT_ID: ${{ secrets.GA_MEASUREMENT_ID }}
GATSBY_ADMG_API: ${{ vars.GATSBY_ADMG_API }}
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v2
- name: Read .nvmrc
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
id: nvm
- name: Use Node.js ${{ steps.nvm.outputs.NVMRC }}
uses: actions/setup-node@v1
with:
node-version: ${{ steps.nvm.outputs.NVMRC }}
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Build
run: |
yarn install
yarn build --prefix-paths
- name: Configure AWS CLI
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: us-west-2
- name: Deploy 🚀
run: |
aws s3 rm s3://${{ secrets.PRODUCTION_BUCKET }} --recursive
aws s3 cp ./public/ s3://${{ secrets.PRODUCTION_BUCKET }}/casei --recursive
aws s3 cp ./public/index.html s3://${{ secrets.PRODUCTION_BUCKET }}
aws s3 cp s3://${{ secrets.STAGING_BUCKET }}/flight-tracks s3://${{ secrets.PRODUCTION_BUCKET }}/casei/flight-tracks --recursive --source-region "us-east-1"
aws cloudfront create-invalidation --distribution-id ${{ secrets.PRODUCTION_DISTRIBUTION_ID }} --paths "/*"
- name: Notify Slack 💃
id: slack
uses: slackapi/[email protected]
with:
payload: '{"text":"Successfully deployed CASEI! <https://impact.earthdata.nasa.gov/casei/|Click here> to take a look!"}'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}