From a35c882a4cc06b9b37e7532b12418aef332e0048 Mon Sep 17 00:00:00 2001 From: Giacomo Licari Date: Wed, 10 Jan 2024 14:25:39 +0100 Subject: [PATCH] Replace Travis with Github Actions --- .github/deploy.yml | 95 +++++++++++++++++++++++++ .idea/.gitignore | 2 - .idea/gnosis-docs.iml | 8 --- .idea/misc.xml | 6 -- .idea/modules.xml | 8 --- .idea/vcs.xml | 6 -- travis/prepare_production_deployment.sh | 17 ----- website/.nvmrc | 1 + 8 files changed, 96 insertions(+), 47 deletions(-) create mode 100644 .github/deploy.yml delete mode 100644 .idea/.gitignore delete mode 100644 .idea/gnosis-docs.iml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml delete mode 100755 travis/prepare_production_deployment.sh create mode 100644 website/.nvmrc diff --git a/.github/deploy.yml b/.github/deploy.yml new file mode 100644 index 0000000..8ac9c23 --- /dev/null +++ b/.github/deploy.yml @@ -0,0 +1,95 @@ +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 + - dev + - release + # Launches build when release is published + release: + types: [published] + +jobs: + deploy: + name: Deployment + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./website + + 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 + + - 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 + run: yarn build + + - name: Configure AWS Development credentials + uses: aws-actions/configure-aws-credentials@v1 + if: ( github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main' ) + with: + aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.DEV_AWS_DEFAULT_REGION }} + + - name: Configure AWS Production credentials + uses: aws-actions/configure-aws-credentials@v1 + if: ( github.ref == 'refs/heads/release' ) + with: + aws-access-key-id: ${{ secrets.PROD_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.PROD_AWS_DEFAULT_REGION }} + + # Script to deploy to development environment + - name: 'Deploy to S3: Development' + if: github.ref == 'refs/heads/dev' + run: | + aws s3 sync build/ s3://${{ secrets.DEV_BUCKET_NAME }}/dev --exclude "*.html" --cache-control max-age=0,no-cache,no-store,public + aws s3 sync build/ s3://${{ secrets.DEV_BUCKET_NAME }}/dev --exclude "*" --include "*.html" --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/html + + # Script to deploy to staging environment + - name: 'Deploy to S3: Staging' + if: github.ref == 'refs/heads/main' + run: | + aws s3 sync build/ s3://${{ secrets.DEV_BUCKET_NAME }}/staging --exclude "*.html" --cache-control max-age=0,no-cache,no-store,public + aws s3 sync build/ s3://${{ secrets.DEV_BUCKET_NAME }}/staging --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 \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index e7e9d11..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Default ignored files -/workspace.xml diff --git a/.idea/gnosis-docs.iml b/.idea/gnosis-docs.iml deleted file mode 100644 index c956989..0000000 --- a/.idea/gnosis-docs.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 24eb271..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 5342f1b..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/travis/prepare_production_deployment.sh b/travis/prepare_production_deployment.sh deleted file mode 100755 index 11acafa..0000000 --- a/travis/prepare_production_deployment.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -set -ev - -# Only: -# - Tagged commits -# - Security env variables are available. -if [ -n "$TRAVIS_TAG" ] && [ -n "$PROD_DEPLOYMENT_HOOK_TOKEN" ] && [ -n "$PROD_DEPLOYMENT_HOOK_URL" ] -then - curl --silent --output /dev/null --write-out "%{http_code}" -X POST \ - -F token="$PROD_DEPLOYMENT_HOOK_TOKEN" \ - -F ref=master \ - -F "variables[TRIGGER_RELEASE_COMMIT_TAG]=$TRAVIS_TAG" \ - $PROD_DEPLOYMENT_HOOK_URL -else - echo "[ERROR] Production deployment could not be prepared" -fi diff --git a/website/.nvmrc b/website/.nvmrc new file mode 100644 index 0000000..0cf077e --- /dev/null +++ b/website/.nvmrc @@ -0,0 +1 @@ +16.14