Merge pull request #485 from gnosischain/main #1080
Workflow file for this run
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: Deploy | |
# Run on pushes to main or PRs | |
on: | |
# Pull request hook without any config. Launches for every pull request | |
pull_request: | |
# Launches for pushes to main or dev | |
push: | |
branches: | |
- main | |
- release | |
# Launches build when release is published | |
release: | |
types: [published] | |
jobs: | |
deploy: | |
name: Deployment | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cancel Previous Runs | |
uses: styfle/cancel-workflow-action@0.8.0 | |
with: | |
access_token: ${{ github.token }} | |
- name: Remove broken apt repos [Ubuntu] | |
if: ${{ matrix.os }} == 'ubuntu-latest' | |
run: | | |
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- uses: actions/cache@v2 | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 16.14.2 | |
- name: Install | |
run: | | |
rm -rf .cache | |
rm -rf build | |
yarn config set cache-folder .yarn | |
yarn install | |
pip install awscli --upgrade --user | |
- name: Build App | |
if: github.ref != 'refs/heads/release' | |
env: | |
ALGOLIA_ID: ${{ secrets.ALGOLIA_ID }} | |
ALGOLIA_INDEX: ${{ secrets.ALGOLIA_INDEX }} | |
ALGOLIA_KEY: ${{ secrets.ALGOLIA_KEY }} | |
GOOGLE_ANALYTICS_ID: ${{ secrets.STAGING_GOOGLE_ANALYTICS_ID }} | |
run: yarn build | |
- name: Build Release App | |
if: github.ref == 'refs/heads/release' | |
env: | |
ALGOLIA_ID: ${{ secrets.ALGOLIA_ID }} | |
ALGOLIA_INDEX: ${{ secrets.ALGOLIA_INDEX }} | |
ALGOLIA_KEY: ${{ secrets.ALGOLIA_KEY }} | |
GOOGLE_ANALYTICS_ID: ${{ secrets.PROD_GOOGLE_ANALYTICS_ID }} | |
run: yarn build | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
if: ( github.ref == 'refs/heads/release' || github.ref == 'refs/heads/main' ) | |
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 }} | |
# Script to deploy to staging environment | |
- name: 'Deploy to S3: Staging' | |
if: github.ref == 'refs/heads/main' | |
run: | | |
aws s3 sync build/ s3://${{ secrets.BUCKET_NAME }}/staging/current --exclude "*.html" --cache-control max-age=0,no-cache,no-store,public | |
aws s3 sync build/ s3://${{ secrets.BUCKET_NAME }}/staging/current --exclude "*" --include "*.html" --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/html | |
# Script to deploy to release environment | |
- name: 'Deploy to S3: Release' | |
if: github.ref == 'refs/heads/release' | |
run: | | |
aws s3 sync build/ s3://${{ secrets.RELEASE_BUCKET_NAME }} --delete --exclude "*.html" --exclude "sitemap.xml" --cache-control max-age=86400,public | |
aws s3 sync build/ s3://${{ secrets.RELEASE_BUCKET_NAME }} --delete --exclude "*" --include "*.html" --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/html | |
aws s3 sync build/ s3://${{ secrets.RELEASE_BUCKET_NAME }} --delete --exclude "*" --include "sitemap.xml" --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/xml |