From 870509eecf21d8bbe9aed71a6ce1adee21ee88d1 Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Wed, 24 Feb 2021 17:24:25 +0100 Subject: [PATCH] Migrate to GitHub actions (#1924) * Add Github action for each network environment * Disable travis build * Move deploy scripts to new folder * Adapt deploy scripts to Github actions * Run coveralls only if tests succeed * Upload sentry source map * Add Production flag for tagged builds * Use coveralls Github Action * Add debug steps to all networks for first release test --- .github/workflows/deploy-ewc.yml | 138 ++++++++++++++ .github/workflows/deploy-mainnet.yml | 120 ++++++++++++ .github/workflows/deploy-rinkeby.yml | 149 +++++++++++++++ .github/workflows/deploy-volta.yml | 141 ++++++++++++++ .github/workflows/deploy-xdai.yml | 141 ++++++++++++++ ...elease.yml => release-mainnet-desktop.yml} | 31 ++-- .github/workflows/test.yml | 43 +++++ .travis.yml | 174 +++++++++--------- scripts/github/deploy_pull_request.sh | 22 +++ .../github}/deploy_release.sh | 13 +- .../github}/prepare_production_deployment.sh | 4 +- 11 files changed, 862 insertions(+), 114 deletions(-) create mode 100644 .github/workflows/deploy-ewc.yml create mode 100644 .github/workflows/deploy-mainnet.yml create mode 100644 .github/workflows/deploy-rinkeby.yml create mode 100644 .github/workflows/deploy-volta.yml create mode 100644 .github/workflows/deploy-xdai.yml rename .github/workflows/{release.yml => release-mainnet-desktop.yml} (79%) create mode 100644 .github/workflows/test.yml create mode 100644 scripts/github/deploy_pull_request.sh rename {config/travis => scripts/github}/deploy_release.sh (51%) rename {config/travis => scripts/github}/prepare_production_deployment.sh (66%) diff --git a/.github/workflows/deploy-ewc.yml b/.github/workflows/deploy-ewc.yml new file mode 100644 index 00000000..3d1993fd --- /dev/null +++ b/.github/workflows/deploy-ewc.yml @@ -0,0 +1,138 @@ +name: Deploy to EWC network + +# Run on pushes to master +on: + push: + branches: + - master + # Launches build when release is published + release: + types: [published] + +env: + REPO_NAME_ALPHANUMERIC: safereact + REACT_APP_NETWORK: 'ewc' + STAGING_BUCKET_NAME: ${{ secrets.STAGING_EWC_BUCKET_NAME }} + REACT_APP_SENTRY_DSN: ${{ secrets.SENTRY_DSN_EWC }} + REACT_APP_GOOGLE_ANALYTICS: ${{ secrets.REACT_APP_GOOGLE_ANALYTICS_ID_EWC }} + REACT_APP_GNOSIS_APPS_URL: ${{ secrets.REACT_APP_GNOSIS_APPS_URL_PROD }} + +jobs: + debug: + name: Debug + runs-on: ubuntu-latest + steps: + - name: Dump env + run: env | sort + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + deploy: + name: Deployment + runs-on: ubuntu-latest + + steps: + - 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 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 14 + + - uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + + - run: | + sudo apt-get update + sudo apt-get -y install python3-pip python3-dev libusb-1.0-0-dev libudev-dev + pip install awscli --upgrade --user + # Due to some dependencies yarn may randomly throw an error about invalid cache + # This approach is taken from https://github.com/yarnpkg/yarn/issues/7212#issuecomment-506155894 to fix the issue + # Another approach is to install with flag --network-concurrency 1, but this will make the installation pretty slow (default value is 8) + mkdir .yarncache + yarn install --cache-folder ./.yarncache --frozen-lockfile + rm -rf .yarncache + yarn cache clean + + # Set production flag + - name: Set production flag for tag build + run: echo "REACT_APP_ENV='production'" >> $GITHUB_ENV + if: startsWith(github.ref, 'refs/tags/v') + + - name: Build ${{ env.REACT_APP_NETWORK }} app + run: yarn build + env: + PUBLIC_URL: './' + REACT_APP_FORTMATIC_KEY: ${{ secrets.REACT_APP_FORTMATIC_KEY }} + REACT_APP_INFURA_TOKEN: ${{ secrets.REACT_APP_INFURA_TOKEN }} + REACT_APP_PORTIS_ID: ${{ secrets.REACT_APP_PORTIS_ID }} + REACT_APP_INTERCOM_ID: ${{ secrets.REACT_APP_INTERCOM_ID }} + REACT_APP_IPFS_GATEWAY: ${{ secrets.REACT_APP_IPFS_GATEWAY }} + + # Script to deploy Pull Requests + - run: bash ./scripts/github/deploy_pull_request.sh + if: success() && github.event.number + env: + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + PR_NUMBER: ${{ github.event.number }} + REVIEW_BUCKET_NAME: ${{ secrets.AWS_REVIEW_BUCKET_NAME }} + REACT_APP_NETWORK: ${{ env.REACT_APP_NETWORK }} + + - name: 'PRaul: Comment PR with app URLs' + uses: mshick/add-pr-comment@v1 + with: + message: | + * [Safe Multisig app ${{ env.REACT_APP_NETWORK }}](${{ env.REVIEW_FEATURE_URL }}/${{ env.REACT_APP_NETWORK }}/app/) + repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token-user-login: 'github-actions[bot]' + allow-repeats: true + if: success() && github.event.number + env: + REVIEW_FEATURE_URL: https://pr${{ github.event.number }}--${{ env.REPO_NAME_ALPHANUMERIC }}.review.gnosisdev.com + + # Script to deploy to development environment + # xDai build is never created in development branch + + # Script to deploy to staging environment + - name: 'Deploy to S3: Staging' + run: bash ./scripts/deploy_to_s3_bucket.sh + if: github.ref == 'refs/heads/master' + env: + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + BUCKET_NAME: ${{ env.STAGING_BUCKET_NAME }} + + # Script to upload release files + - run: bash ./scripts/github/deploy_release.sh + if: startsWith(github.ref, 'refs/tags/v') + env: + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + PR_NUMBER: ${{ github.event.number }} + REVIEW_BUCKET_NAME: ${{ secrets.AWS_REVIEW_BUCKET_NAME }} + REACT_APP_NETWORK: ${{ env.REACT_APP_NETWORK }} + VERSION_TAG: ${{ github.event.release.tag_name }} + + # Script to prepare production deployments + - run: bash ./scripts/github/prepare_production_deployment.sh + if: success() && startsWith(github.ref, 'refs/tags/v') + env: + PROD_DEPLOYMENT_HOOK_TOKEN: ${{ secrets.PROD_DEPLOYMENT_HOOK_TOKEN }} + PROD_DEPLOYMENT_HOOK_URL: ${{ secrets.PROD_DEPLOYMENT_HOOK_URL }} + VERSION_TAG: ${{ github.event.release.tag_name }} + + # Upload Sentry source maps when sending to staging or production + - run: yarn sentry-upload-sourcemaps + if: success() && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_ORG: ${{ secrets.SENTRY_ORG}} + SENTRY_PROJECT: gnosis-safe-multisig-${{ env.REACT_APP_NETWORK }} \ No newline at end of file diff --git a/.github/workflows/deploy-mainnet.yml b/.github/workflows/deploy-mainnet.yml new file mode 100644 index 00000000..7efb0f8f --- /dev/null +++ b/.github/workflows/deploy-mainnet.yml @@ -0,0 +1,120 @@ +name: Deploy to Mainnet network + +# Run on pushes to master +on: + push: + branches: + - master + # Launches build when release is published + release: + types: [published] + +env: + REPO_NAME_ALPHANUMERIC: safereact + REACT_APP_NETWORK: 'mainnet' + STAGING_BUCKET_NAME: ${{ secrets.STAGING_MAINNET_BUCKET_NAME }} + REACT_APP_SENTRY_DSN: ${{ secrets.SENTRY_DSN_MAINNET }} + REACT_APP_GOOGLE_ANALYTICS: ${{ secrets.REACT_APP_GOOGLE_ANALYTICS_ID_MAINNET }} + REACT_APP_GNOSIS_APPS_URL: ${{ secrets.REACT_APP_GNOSIS_APPS_URL_PROD }} + +jobs: + debug: + name: Debug + runs-on: ubuntu-latest + steps: + - name: Dump env + run: env | sort + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + deploy: + name: Deployment + runs-on: ubuntu-latest + + steps: + - 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 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 14 + + - uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + + - run: | + sudo apt-get update + sudo apt-get -y install python3-pip python3-dev libusb-1.0-0-dev libudev-dev + pip install awscli --upgrade --user + # Due to some dependencies yarn may randomly throw an error about invalid cache + # This approach is taken from https://github.com/yarnpkg/yarn/issues/7212#issuecomment-506155894 to fix the issue + # Another approach is to install with flag --network-concurrency 1, but this will make the installation pretty slow (default value is 8) + mkdir .yarncache + yarn install --cache-folder ./.yarncache --frozen-lockfile + rm -rf .yarncache + yarn cache clean + + # Set production flag + - name: Set production flag for tag build + run: echo "REACT_APP_ENV='production'" >> $GITHUB_ENV + if: startsWith(github.ref, 'refs/tags/v') + + - name: Build ${{ env.REACT_APP_NETWORK }} app + run: yarn build + env: + PUBLIC_URL: './' + REACT_APP_FORTMATIC_KEY: ${{ secrets.REACT_APP_FORTMATIC_KEY }} + REACT_APP_INFURA_TOKEN: ${{ secrets.REACT_APP_INFURA_TOKEN }} + REACT_APP_PORTIS_ID: ${{ secrets.REACT_APP_PORTIS_ID }} + REACT_APP_INTERCOM_ID: ${{ secrets.REACT_APP_INTERCOM_ID }} + REACT_APP_IPFS_GATEWAY: ${{ secrets.REACT_APP_IPFS_GATEWAY }} + + # Script to deploy Pull Requests + # Mainnet build is never created in Pull Requests + + # Script to deploy to development environment + # Mainnet build is never created in development branch + + # Script to deploy to staging environment + - name: 'Deploy to S3: Staging' + run: bash ./scripts/deploy_to_s3_bucket.sh + if: github.ref == 'refs/heads/master' + env: + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + BUCKET_NAME: ${{ env.STAGING_BUCKET_NAME }} + + # Script to upload release files + - run: bash ./scripts/github/deploy_release.sh + if: startsWith(github.ref, 'refs/tags/v') + env: + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + PR_NUMBER: ${{ github.event.number }} + REVIEW_BUCKET_NAME: ${{ secrets.AWS_REVIEW_BUCKET_NAME }} + REACT_APP_NETWORK: ${{ env.REACT_APP_NETWORK }} + VERSION_TAG: ${{ github.event.release.tag_name }} + + # Script to prepare production deployments + - run: bash ./scripts/github/prepare_production_deployment.sh + if: success() && startsWith(github.ref, 'refs/tags/v') + env: + PROD_DEPLOYMENT_HOOK_TOKEN: ${{ secrets.PROD_DEPLOYMENT_HOOK_TOKEN }} + PROD_DEPLOYMENT_HOOK_URL: ${{ secrets.PROD_DEPLOYMENT_HOOK_URL }} + VERSION_TAG: ${{ github.event.release.tag_name }} + + # Upload Sentry source maps when sending to staging or production + - run: yarn sentry-upload-sourcemaps + if: success() && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_ORG: ${{ secrets.SENTRY_ORG}} + SENTRY_PROJECT: gnosis-safe-multisig-${{ env.REACT_APP_NETWORK }} + diff --git a/.github/workflows/deploy-rinkeby.yml b/.github/workflows/deploy-rinkeby.yml new file mode 100644 index 00000000..45cc22ea --- /dev/null +++ b/.github/workflows/deploy-rinkeby.yml @@ -0,0 +1,149 @@ +name: Deploy to Rinkeby network + +# Run on pushes to dev/master or PR +on: + # Pull request hook without any config. Launches for every pull request + pull_request: + # Launches for pushes to master or development + push: + branches: + - master + - development + # Launches build when release is published + release: + types: [published] + workflow_dispatch: + +env: + REPO_NAME_ALPHANUMERIC: safereact + REACT_APP_NETWORK: 'rinkeby' + STAGING_BUCKET_NAME: ${{ secrets.STAGING_RINKEBY_BUCKET_NAME }} + REACT_APP_SENTRY_DSN: ${{ secrets.SENTRY_DSN_RINKEBY }} + REACT_APP_GOOGLE_ANALYTICS: ${{ secrets.REACT_APP_GOOGLE_ANALYTICS_ID_RINKEBY }} + REACT_APP_GNOSIS_APPS_URL: ${{ secrets.REACT_APP_GNOSIS_APPS_URL_PROD }} + +jobs: + debug: + name: Debug + runs-on: ubuntu-latest + steps: + - name: Dump env + run: env | sort + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + deploy: + name: Deployment + runs-on: ubuntu-latest + steps: + - 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 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 14 + + - uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + + - run: | + sudo apt-get update + sudo apt-get -y install python3-pip python3-dev libusb-1.0-0-dev libudev-dev + pip install awscli --upgrade --user + # Due to some dependencies yarn may randomly throw an error about invalid cache + # This approach is taken from https://github.com/yarnpkg/yarn/issues/7212#issuecomment-506155894 to fix the issue + # Another approach is to install with flag --network-concurrency 1, but this will make the installation pretty slow (default value is 8) + mkdir .yarncache + yarn install --cache-folder ./.yarncache --frozen-lockfile + rm -rf .yarncache + yarn cache clean + + # Set production flag + - name: Set production flag for tag build + run: echo "REACT_APP_ENV='production'" >> $GITHUB_ENV + if: startsWith(github.ref, 'refs/tags/v') + + - name: Build ${{ env.REACT_APP_NETWORK }} app ${{ env.REACT_APP_ENV }} + run: yarn build + env: + PUBLIC_URL: './' + REACT_APP_FORTMATIC_KEY: ${{ secrets.REACT_APP_FORTMATIC_KEY }} + REACT_APP_INFURA_TOKEN: ${{ secrets.REACT_APP_INFURA_TOKEN }} + REACT_APP_PORTIS_ID: ${{ secrets.REACT_APP_PORTIS_ID }} + REACT_APP_INTERCOM_ID: ${{ secrets.REACT_APP_INTERCOM_ID }} + REACT_APP_IPFS_GATEWAY: ${{ secrets.REACT_APP_IPFS_GATEWAY }} + + # Script to deploy Pull Requests + - run: bash ./scripts/github/deploy_pull_request.sh + if: success() && github.event.number + env: + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + PR_NUMBER: ${{ github.event.number }} + REVIEW_BUCKET_NAME: ${{ secrets.AWS_REVIEW_BUCKET_NAME }} + REACT_APP_NETWORK: ${{ env.REACT_APP_NETWORK }} + TRAVIS_TAG: ${{ github.event.release.tag_name }} + + - name: 'PRaul: Comment PR with app URLs' + uses: mshick/add-pr-comment@v1 + with: + message: | + * [Safe Multisig app ${{ env.REACT_APP_NETWORK }}](${{ env.REVIEW_FEATURE_URL }}/${{ env.REACT_APP_NETWORK }}/app/) + repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token-user-login: 'github-actions[bot]' + allow-repeats: true + if: success() && github.event.number + env: + REVIEW_FEATURE_URL: https://pr${{ github.event.number }}--${{ env.REPO_NAME_ALPHANUMERIC }}.review.gnosisdev.com + + # Script to deploy to development environment + - name: 'Deploy to S3: Develop' + run: bash ./scripts/deploy_to_s3_bucket.sh + if: github.ref == 'refs/heads/development' + env: + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + BUCKET_NAME: ${{ secrets.AWS_DEV_BUCKET_NAME }} + + # Script to deploy to staging environment + - name: 'Deploy to S3: Staging' + run: bash ./scripts/deploy_to_s3_bucket.sh + if: github.ref == 'refs/heads/master' + env: + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + BUCKET_NAME: ${{ env.STAGING_BUCKET_NAME }} + + # Script to upload release files + - run: bash ./scripts/github/deploy_release.sh + if: startsWith(github.ref, 'refs/tags/v') + env: + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + PR_NUMBER: ${{ github.event.number }} + REVIEW_BUCKET_NAME: ${{ secrets.AWS_REVIEW_BUCKET_NAME }} + REACT_APP_NETWORK: ${{ env.REACT_APP_NETWORK }} + VERSION_TAG: ${{ github.event.release.tag_name }} + + # Script to prepare production deployments + - run: bash ./scripts/github/prepare_production_deployment.sh + if: success() && startsWith(github.ref, 'refs/tags/v') + env: + PROD_DEPLOYMENT_HOOK_TOKEN: ${{ secrets.PROD_DEPLOYMENT_HOOK_TOKEN }} + PROD_DEPLOYMENT_HOOK_URL: ${{ secrets.PROD_DEPLOYMENT_HOOK_URL }} + VERSION_TAG: ${{ github.event.release.tag_name }} + + # Upload Sentry source maps when sending to staging or production + - run: yarn sentry-upload-sourcemaps + if: success() && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_ORG: ${{ secrets.SENTRY_ORG}} + SENTRY_PROJECT: gnosis-safe-multisig-${{ env.REACT_APP_NETWORK }} diff --git a/.github/workflows/deploy-volta.yml b/.github/workflows/deploy-volta.yml new file mode 100644 index 00000000..20d3f9d5 --- /dev/null +++ b/.github/workflows/deploy-volta.yml @@ -0,0 +1,141 @@ +name: Deploy to Volta network + +# Run on pushes to master or PRs to master +on: + push: + branches: + - master + pull_request: + branches: + - master + # Launches build when release is published + release: + types: [published] + +env: + REPO_NAME_ALPHANUMERIC: safereact + REACT_APP_NETWORK: 'volta' + STAGING_BUCKET_NAME: ${{ secrets.STAGING_VOLTA_BUCKET_NAME }} + REACT_APP_SENTRY_DSN: ${{ secrets.SENTRY_DSN_VOLTA }} + REACT_APP_GOOGLE_ANALYTICS: ${{ secrets.REACT_APP_GOOGLE_ANALYTICS_ID_VOLTA }} + REACT_APP_GNOSIS_APPS_URL: ${{ secrets.REACT_APP_GNOSIS_APPS_URL_PROD }} + +jobs: + debug: + name: Debug + runs-on: ubuntu-latest + steps: + - name: Dump env + run: env | sort + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + deploy: + name: Deployment + runs-on: ubuntu-latest + + steps: + - 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 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 14 + + - uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + + - run: | + sudo apt-get update + sudo apt-get -y install python3-pip python3-dev libusb-1.0-0-dev libudev-dev + pip install awscli --upgrade --user + # Due to some dependencies yarn may randomly throw an error about invalid cache + # This approach is taken from https://github.com/yarnpkg/yarn/issues/7212#issuecomment-506155894 to fix the issue + # Another approach is to install with flag --network-concurrency 1, but this will make the installation pretty slow (default value is 8) + mkdir .yarncache + yarn install --cache-folder ./.yarncache --frozen-lockfile + rm -rf .yarncache + yarn cache clean + + # Set production flag + - name: Set production flag for tag build + run: echo "REACT_APP_ENV='production'" >> $GITHUB_ENV + if: startsWith(github.ref, 'refs/tags/v') + + - name: Build ${{ env.REACT_APP_NETWORK }} app + run: yarn build + env: + PUBLIC_URL: './' + REACT_APP_FORTMATIC_KEY: ${{ secrets.REACT_APP_FORTMATIC_KEY }} + REACT_APP_INFURA_TOKEN: ${{ secrets.REACT_APP_INFURA_TOKEN }} + REACT_APP_PORTIS_ID: ${{ secrets.REACT_APP_PORTIS_ID }} + REACT_APP_INTERCOM_ID: ${{ secrets.REACT_APP_INTERCOM_ID }} + REACT_APP_IPFS_GATEWAY: ${{ secrets.REACT_APP_IPFS_GATEWAY }} + + # Script to deploy Pull Requests + - run: bash ./scripts/github/deploy_pull_request.sh + if: success() && github.event.number + env: + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + PR_NUMBER: ${{ github.event.number }} + REVIEW_BUCKET_NAME: ${{ secrets.AWS_REVIEW_BUCKET_NAME }} + REACT_APP_NETWORK: ${{ env.REACT_APP_NETWORK }} + + - name: 'PRaul: Comment PR with app URLs' + uses: mshick/add-pr-comment@v1 + with: + message: | + * [Safe Multisig app ${{ env.REACT_APP_NETWORK }}](${{ env.REVIEW_FEATURE_URL }}/${{ env.REACT_APP_NETWORK }}/app/) + repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token-user-login: 'github-actions[bot]' + allow-repeats: true + if: success() && github.event.number + env: + REVIEW_FEATURE_URL: https://pr${{ github.event.number }}--${{ env.REPO_NAME_ALPHANUMERIC }}.review.gnosisdev.com + + # Script to deploy to development environment + # xDai build is never created in development branch + + # Script to deploy to staging environment + - name: 'Deploy to S3: Staging' + run: bash ./scripts/deploy_to_s3_bucket.sh + if: github.ref == 'refs/heads/master' + env: + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + BUCKET_NAME: ${{ env.STAGING_BUCKET_NAME }} + + # Script to upload release files + - run: bash ./scripts/github/deploy_release.sh + if: startsWith(github.ref, 'refs/tags/v') + env: + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + PR_NUMBER: ${{ github.event.number }} + REVIEW_BUCKET_NAME: ${{ secrets.AWS_REVIEW_BUCKET_NAME }} + REACT_APP_NETWORK: ${{ env.REACT_APP_NETWORK }} + VERSION_TAG: ${{ github.event.release.tag_name }} + + # Script to prepare production deployments + - run: bash ./scripts/github/prepare_production_deployment.sh + if: success() && startsWith(github.ref, 'refs/tags/v') + env: + PROD_DEPLOYMENT_HOOK_TOKEN: ${{ secrets.PROD_DEPLOYMENT_HOOK_TOKEN }} + PROD_DEPLOYMENT_HOOK_URL: ${{ secrets.PROD_DEPLOYMENT_HOOK_URL }} + VERSION_TAG: ${{ github.event.release.tag_name }} + + # Upload Sentry source maps when sending to staging or production + - run: yarn sentry-upload-sourcemaps + if: success() && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_ORG: ${{ secrets.SENTRY_ORG}} + SENTRY_PROJECT: gnosis-safe-multisig-${{ env.REACT_APP_NETWORK }} diff --git a/.github/workflows/deploy-xdai.yml b/.github/workflows/deploy-xdai.yml new file mode 100644 index 00000000..eb472d46 --- /dev/null +++ b/.github/workflows/deploy-xdai.yml @@ -0,0 +1,141 @@ +name: Deploy to xDai network + +# Run on pushes to master or PRs to master +on: + push: + branches: + - master + pull_request: + branches: + - master + # Launches build when release is published + release: + types: [published] + +env: + REPO_NAME_ALPHANUMERIC: safereact + REACT_APP_NETWORK: 'xdai' + STAGING_BUCKET_NAME: ${{ secrets.STAGING_XDAI_BUCKET_NAME }} + REACT_APP_SENTRY_DSN: ${{ secrets.SENTRY_DSN_XDAI }} + REACT_APP_GOOGLE_ANALYTICS: ${{ secrets.REACT_APP_GOOGLE_ANALYTICS_ID_XDAI }} + REACT_APP_GNOSIS_APPS_URL: ${{ secrets.REACT_APP_GNOSIS_APPS_URL_PROD }} + +jobs: + debug: + name: Debug + runs-on: ubuntu-latest + steps: + - name: Dump env + run: env | sort + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + deploy: + name: Deployment + runs-on: ubuntu-latest + + steps: + - 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 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 14 + + - uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + + - run: | + sudo apt-get update + sudo apt-get -y install python3-pip python3-dev libusb-1.0-0-dev libudev-dev + pip install awscli --upgrade --user + # Due to some dependencies yarn may randomly throw an error about invalid cache + # This approach is taken from https://github.com/yarnpkg/yarn/issues/7212#issuecomment-506155894 to fix the issue + # Another approach is to install with flag --network-concurrency 1, but this will make the installation pretty slow (default value is 8) + mkdir .yarncache + yarn install --cache-folder ./.yarncache --frozen-lockfile + rm -rf .yarncache + yarn cache clean + + # Set production flag + - name: Set production flag for tag build + run: echo "REACT_APP_ENV='production'" >> $GITHUB_ENV + if: startsWith(github.ref, 'refs/tags/v') + + - name: Build ${{ env.REACT_APP_NETWORK }} app + run: yarn build + env: + PUBLIC_URL: './' + REACT_APP_FORTMATIC_KEY: ${{ secrets.REACT_APP_FORTMATIC_KEY }} + REACT_APP_INFURA_TOKEN: ${{ secrets.REACT_APP_INFURA_TOKEN }} + REACT_APP_PORTIS_ID: ${{ secrets.REACT_APP_PORTIS_ID }} + REACT_APP_INTERCOM_ID: ${{ secrets.REACT_APP_INTERCOM_ID }} + REACT_APP_IPFS_GATEWAY: ${{ secrets.REACT_APP_IPFS_GATEWAY }} + + # Script to deploy Pull Requests + - run: bash ./scripts/github/deploy_pull_request.sh + if: success() && github.event.number + env: + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + PR_NUMBER: ${{ github.event.number }} + REVIEW_BUCKET_NAME: ${{ secrets.AWS_REVIEW_BUCKET_NAME }} + REACT_APP_NETWORK: ${{ env.REACT_APP_NETWORK }} + + - name: 'PRaul: Comment PR with app URLs' + uses: mshick/add-pr-comment@v1 + with: + message: | + * [Safe Multisig app ${{ env.REACT_APP_NETWORK }}](${{ env.REVIEW_FEATURE_URL }}/${{ env.REACT_APP_NETWORK }}/app/) + repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token-user-login: 'github-actions[bot]' + allow-repeats: true + if: success() && github.event.number + env: + REVIEW_FEATURE_URL: https://pr${{ github.event.number }}--${{ env.REPO_NAME_ALPHANUMERIC }}.review.gnosisdev.com + + # Script to deploy to development environment + # xDai build is never created in development branch + + # Script to deploy to staging environment + - name: 'Deploy to S3: Staging' + run: bash ./scripts/deploy_to_s3_bucket.sh + if: github.ref == 'refs/heads/master' + env: + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + BUCKET_NAME: ${{ env.STAGING_BUCKET_NAME }} + + # Script to upload release files + - run: bash ./scripts/github/deploy_release.sh + if: startsWith(github.ref, 'refs/tags/v') + env: + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + PR_NUMBER: ${{ github.event.number }} + REVIEW_BUCKET_NAME: ${{ secrets.AWS_REVIEW_BUCKET_NAME }} + REACT_APP_NETWORK: ${{ env.REACT_APP_NETWORK }} + VERSION_TAG: ${{ github.event.release.tag_name }} + + # Script to prepare production deployments + - run: bash ./scripts/github/prepare_production_deployment.sh + if: success() && startsWith(github.ref, 'refs/tags/v') + env: + PROD_DEPLOYMENT_HOOK_TOKEN: ${{ secrets.PROD_DEPLOYMENT_HOOK_TOKEN }} + PROD_DEPLOYMENT_HOOK_URL: ${{ secrets.PROD_DEPLOYMENT_HOOK_URL }} + VERSION_TAG: ${{ github.event.release.tag_name }} + + # Upload Sentry source maps when sending to staging or production + - run: yarn sentry-upload-sourcemaps + if: success() && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_ORG: ${{ secrets.SENTRY_ORG}} + SENTRY_PROJECT: gnosis-safe-multisig-${{ env.REACT_APP_NETWORK }} diff --git a/.github/workflows/release.yml b/.github/workflows/release-mainnet-desktop.yml similarity index 79% rename from .github/workflows/release.yml rename to .github/workflows/release-mainnet-desktop.yml index 9ff9aa1d..ac95cf22 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release-mainnet-desktop.yml @@ -1,4 +1,4 @@ -name: Build/Release Desktop app +name: Build/Release Mainnet desktop app # this will help you specify where to run on: @@ -6,10 +6,9 @@ on: env: REACT_APP_FORTMATIC_KEY: ${{ secrets.REACT_APP_FORTMATIC_KEY }} - REACT_APP_GOOGLE_ANALYTICS_ID_MAINNET: ${{ secrets.REACT_APP_GOOGLE_ANALYTICS_ID_MAINNET }} REACT_APP_INFURA_TOKEN: ${{ secrets.REACT_APP_INFURA_TOKEN }} REACT_APP_PORTIS_ID: ${{ secrets.REACT_APP_PORTIS_ID }} - REACT_APP_GNOSIS_APPS_URL: ${{ secrets.REACT_APP_GNOSIS_APPS_URL }} + REACT_APP_GNOSIS_APPS_URL: ${{ secrets.REACT_APP_GNOSIS_APPS_URL_PROD }} REACT_APP_INTERCOM_ID: ${{ secrets.REACT_APP_INTERCOM_ID }} REACT_APP_IPFS_GATEWAY: ${{ secrets.REACT_APP_IPFS_GATEWAY }} jobs: @@ -26,18 +25,10 @@ jobs: - name: Check out Git repository uses: actions/checkout@v2 - # Add cache for yarn directory - # - name: Get yarn cache directory path - # id: yarn-cache-dir-path - # run: echo "::set-output name=dir::$(yarn cache dir)" - - # - uses: actions/cache@v2 - # id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) - # with: - # path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - # key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - # restore-keys: | - # ${{ runner.os }}-yarn- + - uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - name: Patch node gyp on windows to support Visual Studio 2019 if: startsWith(matrix.os, 'windows') @@ -54,7 +45,15 @@ jobs: uses: actions/setup-node@v2 with: node-version: 14 - - run: yarn install --frozen-lockfile --network-concurrency 1 + - run: | + # Due to some dependencies yarn may randomly throw an error about invalid cache + # This approach is taken from https://github.com/yarnpkg/yarn/issues/7212#issuecomment-506155894 to fix the issue + # Another approach is to install with flag --network-concurrency 1, but this will make the installation pretty slow (default value is 8) + mkdir .yarncache + yarn install --cache-folder ./.yarncache --frozen-lockfile + rm -rf .yarncache + yarn cache clean + - name: Build/Release Desktop App env: # macOS notarization API key diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..147dbfda --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,43 @@ +name: Run app tests +on: + pull_request: + push: + branches: + - master + - development + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 14 + + - uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + + - run: | + sudo apt-get update + sudo apt-get -y install python3-pip python3-dev libusb-1.0-0-dev libudev-dev + pip install awscli --upgrade --user + # Due to some dependencies yarn may randomly throw an error about invalid cache + # This approach is taken from https://github.com/yarnpkg/yarn/issues/7212#issuecomment-506155894 to fix the issue + # Another approach is to install with flag --network-concurrency 1, but this will make the installation pretty slow (default value is 8) + mkdir .yarncache + yarn install --cache-folder ./.yarncache --frozen-lockfile + rm -rf .yarncache + yarn cache clean + + - run: yarn test:coverage + + - name: Upload coverage to Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + if: success() + diff --git a/.travis.yml b/.travis.yml index 8ee6afc9..4608ec9d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ -if: (branch = development) OR (branch = master) OR (type = pull_request) OR (tag IS present) +# if: (branch = development) OR (branch = master) OR (type = pull_request) OR (tag IS present) +if: (branch = master) OR (tag IS present) dist: focal language: node_js node_js: @@ -6,42 +7,43 @@ node_js: os: - linux matrix: - include: - - env: - - REACT_APP_NETWORK='mainnet' - - STAGING_BUCKET_NAME=${STAGING_MAINNET_BUCKET_NAME} - - REACT_APP_SENTRY_DSN=${SENTRY_DSN_MAINNET} - - SENTRY_PROJECT=${SENTRY_PROJECT_MAINNET} - - REACT_APP_GOOGLE_ANALYTICS=${REACT_APP_GOOGLE_ANALYTICS_ID_MAINNET} - - REACT_APP_GNOSIS_APPS_URL=${REACT_APP_GNOSIS_APPS_URL_PROD} - if: (branch = master AND NOT type = pull_request) OR tag IS present - - env: - - REACT_APP_NETWORK='rinkeby' - - REACT_APP_SENTRY_DSN=${SENTRY_DSN_RINKEBY} - - SENTRY_PROJECT=${SENTRY_PROJECT_RINKEBY} - - REACT_APP_GOOGLE_ANALYTICS=${REACT_APP_GOOGLE_ANALYTICS_ID_RINKEBY} - - REACT_APP_GNOSIS_APPS_URL=${REACT_APP_GNOSIS_APPS_URL_STAGING} - - env: - - REACT_APP_NETWORK='xdai' - - STAGING_BUCKET_NAME=${STAGING_XDAI_BUCKET_NAME} - - REACT_APP_SENTRY_DSN=${SENTRY_DSN_XDAI} - - SENTRY_PROJECT=${SENTRY_PROJECT_XDAI} - - REACT_APP_GOOGLE_ANALYTICS=${REACT_APP_GOOGLE_ANALYTICS_ID_XDAI} - if: (branch = master) OR tag IS present - - env: - - REACT_APP_NETWORK='volta' - - STAGING_BUCKET_NAME=${STAGING_VOLTA_BUCKET_NAME} - - REACT_APP_SENTRY_DSN=${SENTRY_DSN_VOLTA} - - SENTRY_PROJECT=${SENTRY_PROJECT_VOLTA} - - REACT_APP_GOOGLE_ANALYTICS=${REACT_APP_GOOGLE_ANALYTICS_ID_VOLTA} - if: (branch = master) OR tag IS present - - env: - - REACT_APP_NETWORK='energy_web_chain' - - STAGING_BUCKET_NAME=${STAGING_EWC_BUCKET_NAME} - - REACT_APP_SENTRY_DSN=${SENTRY_DSN_EWC} - - SENTRY_PROJECT=${SENTRY_PROJECT_EWC} - - REACT_APP_GOOGLE_ANALYTICS=${REACT_APP_GOOGLE_ANALYTICS_ID_EWC} - if: (branch = master AND NOT type = pull_request) OR tag IS present + # include: + # - env: + # - REACT_APP_NETWORK='mainnet' + # - STAGING_BUCKET_NAME=${STAGING_MAINNET_BUCKET_NAME} + # - REACT_APP_SENTRY_DSN=${SENTRY_DSN_MAINNET} + # - SENTRY_PROJECT=${SENTRY_PROJECT_MAINNET} + # - REACT_APP_GOOGLE_ANALYTICS=${REACT_APP_GOOGLE_ANALYTICS_ID_MAINNET} + # - REACT_APP_GNOSIS_APPS_URL=${REACT_APP_GNOSIS_APPS_URL_PROD} + # if: (branch = master AND NOT type = pull_request) OR tag IS present + # - env: + # - REACT_APP_NETWORK='rinkeby' + # - REACT_APP_SENTRY_DSN=${SENTRY_DSN_RINKEBY} + # - SENTRY_PROJECT=${SENTRY_PROJECT_RINKEBY} + # - REACT_APP_GOOGLE_ANALYTICS=${REACT_APP_GOOGLE_ANALYTICS_ID_RINKEBY} + # - REACT_APP_GNOSIS_APPS_URL=${REACT_APP_GNOSIS_APPS_URL_STAGING} + # if: (branch = development AND NOT type = pull_request) OR (branch = master) OR tag IS present + # - env: + # - REACT_APP_NETWORK='xdai' + # - STAGING_BUCKET_NAME=${STAGING_XDAI_BUCKET_NAME} + # - REACT_APP_SENTRY_DSN=${SENTRY_DSN_XDAI} + # - SENTRY_PROJECT=${SENTRY_PROJECT_XDAI} + # - REACT_APP_GOOGLE_ANALYTICS=${REACT_APP_GOOGLE_ANALYTICS_ID_XDAI} + # if: (branch = master) OR tag IS present + # - env: + # - REACT_APP_NETWORK='volta' + # - STAGING_BUCKET_NAME=${STAGING_VOLTA_BUCKET_NAME} + # - REACT_APP_SENTRY_DSN=${SENTRY_DSN_VOLTA} + # - SENTRY_PROJECT=${SENTRY_PROJECT_VOLTA} + # - REACT_APP_GOOGLE_ANALYTICS=${REACT_APP_GOOGLE_ANALYTICS_ID_VOLTA} + # if: (branch = master) OR tag IS present + # - env: + # - REACT_APP_NETWORK='energy_web_chain' + # - STAGING_BUCKET_NAME=${STAGING_EWC_BUCKET_NAME} + # - REACT_APP_SENTRY_DSN=${SENTRY_DSN_EWC} + # - SENTRY_PROJECT=${SENTRY_PROJECT_EWC} + # - REACT_APP_GOOGLE_ANALYTICS=${REACT_APP_GOOGLE_ANALYTICS_ID_EWC} + # if: (branch = master AND NOT type = pull_request) OR tag IS present cache: npm: false yarn: true @@ -50,65 +52,65 @@ before_script: - if [ $TRAVIS_PULL_REQUEST != "false" ]; then export PUBLIC_URL="/${REACT_APP_NETWORK}/app"; fi; before_install: # Needed to deploy pull request and releases - - sudo apt-get update - - sudo apt-get -y install python3-pip python3-dev libusb-1.0-0-dev libudev-dev - - pip install awscli --upgrade --user + # - sudo apt-get update + # - sudo apt-get -y install python3-pip python3-dev libusb-1.0-0-dev libudev-dev + # - pip install awscli --upgrade --user script: - yarn prettier:check - - yarn test:coverage - - yarn build - - if [[ $TRAVIS_BRANCH == "master" && $TRAVIS_PULL_REQUEST == "false" ]] || [ -n "$TRAVIS_TAG" ]; then - echo "Upload sentry source maps"; - yarn sentry-upload-sourcemaps; - else - echo "Skip source map upload"; - fi; + # - yarn test:coverage + # - yarn build + # - if [[ $TRAVIS_BRANCH == "master" && $TRAVIS_PULL_REQUEST == "false" ]] || [ -n "$TRAVIS_TAG" ]; then + # echo "Upload sentry source maps"; + # yarn sentry-upload-sourcemaps; + # else + # echo "Skip source map upload"; + # fi; after_success: # Pull Request - Deploy it to a review environment # Travis doesn't do deploy step with pull requests builds - - ./config/travis/deploy_pull_request.sh + # - ./config/travis/deploy_pull_request.sh # Releases (tagged commits) - Deploy it to a release environment - - ./config/travis/deploy_release.sh - - yarn coveralls + # - ./config/travis/deploy_release.sh + # - yarn coveralls deploy: # Development environment only on rinkeby - - provider: s3 - bucket: $DEV_BUCKET_NAME - access_key_id: $AWS_ACCESS_KEY_ID - secret_access_key: $AWS_SECRET_ACCESS_KEY - skip_cleanup: true - local_dir: build - upload_dir: app - region: $AWS_DEFAULT_REGION - on: - branch: development - condition: $REACT_APP_NETWORK = rinkeby + # - provider: s3 + # bucket: $DEV_BUCKET_NAME + # access_key_id: $AWS_ACCESS_KEY_ID + # secret_access_key: $AWS_SECRET_ACCESS_KEY + # skip_cleanup: true + # local_dir: build + # upload_dir: app + # region: $AWS_DEFAULT_REGION + # on: + # branch: development + # condition: $REACT_APP_NETWORK = rinkeby # Staging environment - - provider: s3 - bucket: $STAGING_BUCKET_NAME - access_key_id: $AWS_ACCESS_KEY_ID - secret_access_key: $AWS_SECRET_ACCESS_KEY - skip_cleanup: true - local_dir: build - upload_dir: current/app - region: $AWS_DEFAULT_REGION - on: - branch: master + # - provider: s3 + # bucket: $STAGING_BUCKET_NAME + # access_key_id: $AWS_ACCESS_KEY_ID + # secret_access_key: $AWS_SECRET_ACCESS_KEY + # skip_cleanup: true + # local_dir: build + # upload_dir: current/app + # region: $AWS_DEFAULT_REGION + # on: + # branch: master # Prepare production deployment - - provider: s3 - bucket: $STAGING_BUCKET_NAME - secret_access_key: $AWS_SECRET_ACCESS_KEY - access_key_id: $AWS_ACCESS_KEY_ID - skip_cleanup: true - local_dir: build - upload_dir: releases/$TRAVIS_TAG - region: $AWS_DEFAULT_REGION - on: - tags: true - - provider: script - script: ./config/travis/prepare_production_deployment.sh - on: - tags: true + # - provider: s3 + # bucket: $STAGING_BUCKET_NAME + # secret_access_key: $AWS_SECRET_ACCESS_KEY + # access_key_id: $AWS_ACCESS_KEY_ID + # skip_cleanup: true + # local_dir: build + # upload_dir: releases/$TRAVIS_TAG + # region: $AWS_DEFAULT_REGION + # on: + # tags: true + # - provider: script + # script: ./config/travis/prepare_production_deployment.sh + # on: + # tags: true diff --git a/scripts/github/deploy_pull_request.sh b/scripts/github/deploy_pull_request.sh new file mode 100644 index 00000000..77bea21e --- /dev/null +++ b/scripts/github/deploy_pull_request.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +function deploy_pull_request { + # Pull request number with "pr" prefix + PULL_REQUEST_NUMBER="pr$PR_NUMBER" + + # Only alphanumeric characters. Example safe-react -> safereact + REVIEW_FEATURE_FOLDER="$REPO_NAME_ALPHANUMERIC/$PULL_REQUEST_NUMBER" + + # App build path + APP_PATH="./build" + + # Deploy pull request + aws s3 sync $APP_PATH s3://${REVIEW_BUCKET_NAME}/${REVIEW_FEATURE_FOLDER}/${REACT_APP_NETWORK}/app --delete +} + +# Only: +# - Pull requests +# - Security env variables are available. PR from forks don't have them. +if [ -n "$AWS_ACCESS_KEY_ID" ]; then + deploy_pull_request +fi \ No newline at end of file diff --git a/config/travis/deploy_release.sh b/scripts/github/deploy_release.sh similarity index 51% rename from config/travis/deploy_release.sh rename to scripts/github/deploy_release.sh index b7d1d5d3..140e659d 100755 --- a/config/travis/deploy_release.sh +++ b/scripts/github/deploy_release.sh @@ -3,19 +3,12 @@ # Only: # - Tagged commits # - Security env variables are available. -if [ -n "$TRAVIS_TAG" ] && [ -n "$AWS_ACCESS_KEY_ID" ] +if [ -n "$VERSION_TAG" ] && [ -n "$AWS_ACCESS_KEY_ID" ] then - REVIEW_ENVIRONMENT_DOMAIN='review.gnosisdev.com' - - # Feature name without all path. Example gnosis/pm-trading-ui -> pm-trading-ui - REPO_NAME=$(basename $TRAVIS_REPO_SLUG) - # Only alphanumeric characters. Example pm-trading-ui -> pmtradingui - REPO_NAME_ALPHANUMERIC=$(echo $REPO_NAME | sed 's/[^a-zA-Z0-9]//g') - # Only alphanumeric characters. Example v1.0.0 -> v100 - TRAVIS_TAG_ALPHANUMERIC=$(echo $TRAVIS_TAG | sed 's/[^a-zA-Z0-9]//g') + VERSION_TAG_ALPHANUMERIC=$(echo $VERSION_TAG | sed 's/[^a-zA-Z0-9]//g') - REVIEW_RELEASE_FOLDER="$REPO_NAME_ALPHANUMERIC/$TRAVIS_TAG_ALPHANUMERIC" + REVIEW_RELEASE_FOLDER="$REPO_NAME_ALPHANUMERIC/$VERSION_TAG_ALPHANUMERIC" # Deploy safe-team release project aws s3 sync build s3://${REVIEW_BUCKET_NAME}/${REVIEW_RELEASE_FOLDER}/app --delete --exclude "*.html" --exclude "/page-data" --cache-control max-age=31536000,public diff --git a/config/travis/prepare_production_deployment.sh b/scripts/github/prepare_production_deployment.sh similarity index 66% rename from config/travis/prepare_production_deployment.sh rename to scripts/github/prepare_production_deployment.sh index e49e03b7..48f88043 100755 --- a/config/travis/prepare_production_deployment.sh +++ b/scripts/github/prepare_production_deployment.sh @@ -5,12 +5,12 @@ set -ev # Only: # - Tagged commits # - Security env variables are available. -if [ -n "$TRAVIS_TAG" ] && [ -n "$PROD_DEPLOYMENT_HOOK_TOKEN" ] && [ -n "$PROD_DEPLOYMENT_HOOK_URL" ] +if [ -n "$VERSION_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" \ + -F "variables[TRIGGER_RELEASE_COMMIT_TAG]=$VERSION_TAG" \ $PROD_DEPLOYMENT_HOOK_URL else echo "[ERROR] Production deployment could not be prepared"