Deploy Apps #1703
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 Apps | |
# Run on pushes to dev/main or PR | |
on: | |
# Pull request hook without any config. Launches for every pull request | |
pull_request: | |
# Launches for pushes to main or dev | |
push: | |
branches: | |
- main | |
- development | |
# Run manually to version/production deployment/github releases | |
workflow_dispatch: | |
env: | |
REPO_NAME_ALPHANUMERIC: safereactapps | |
HUSKY: 0 | |
jobs: | |
pr: | |
name: Pull Request | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'pull_request' }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
fetch-depth: 0 | |
- uses: ./.github/actions/setup-env | |
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 }} | |
- name: Derive appropriate SHAs for base and head for `nx affected` commands | |
uses: nrwl/nx-set-shas@v2 | |
- name: Test, Build, Deploy PR | |
run: | | |
npx nx affected --target=test | |
npx nx affected --target=build | |
npx nx affected --target=deploy:pr | |
env: | |
PR_NUMBER: ${{ github.event.number }} | |
REVIEW_BUCKET_NAME: ${{ secrets.AWS_REVIEW_BUCKET_NAME }} | |
REACT_APP_TENDERLY_ORG_NAME: ${{ secrets.REACT_APP_TENDERLY_ORG_NAME }} | |
REACT_APP_TENDERLY_SIMULATE_ENDPOINT_URL: ${{ secrets.REACT_APP_TENDERLY_SIMULATE_ENDPOINT_URL }} | |
REACT_APP_TENDERLY_PROJECT_NAME: ${{ secrets.REACT_APP_TENDERLY_PROJECT_NAME }} | |
REACT_APP_MMI_BACKEND_BASE_URL: ${{ secrets.MMI_BACKEND_BASE_URL }} | |
REACT_APP_MMI_ENVIRONMENT: ${{ secrets.MMI_ENVIRONMENT }} | |
REACT_APP_WALLETCONNECT_PROJECT_ID: ${{ secrets.REACT_APP_WALLETCONNECT_PROJECT_ID_DEVSTAGING }} | |
REACT_APP_RAMP_APIKEY: ${{ secrets.REACT_APP_RAMP_APIKEY }} | |
- name: 'PRaul: Comment PR with app URLs' | |
if: success() && github.event.number | |
uses: mshick/add-pr-comment@v1 | |
with: | |
message: | | |
* [Drain Account App](${{ env.REVIEW_FEATURE_URL }}/drain-safe/) | |
* [RAMP Network App](${{ env.REVIEW_FEATURE_URL }}/ramp-network/) | |
* [Sign-In With Ethereum Delegate Manager App](${{ env.REVIEW_FEATURE_URL }}/siwe-delegate-manager/) | |
* [Tx Builder App](${{ env.REVIEW_FEATURE_URL }}/tx-builder/) | |
* [WalletConnect app](${{ env.REVIEW_FEATURE_URL }}/wallet-connect/) | |
* [MMI App](${{ env.REVIEW_FEATURE_URL }}/mmi/) | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
repo-token-user-login: 'github-actions[bot]' | |
env: | |
REVIEW_FEATURE_URL: https://pr${{ github.event.number }}--${{ env.REPO_NAME_ALPHANUMERIC }}.review-react-hr.5afe.dev | |
deploy: | |
name: Deploy Dev/Staging | |
runs-on: ubuntu-latest | |
if: github.event_name != 'pull_request' && github.event_name != 'workflow_dispatch' | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: ./.github/actions/setup-env | |
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 }} | |
- name: Derive appropriate SHAs for base and head for `nx affected` commands | |
uses: nrwl/nx-set-shas@v2 | |
- name: Test and Build | |
run: | | |
npx nx affected --target=test --parallel | |
npx nx affected --target=build --parallel | |
env: | |
REACT_APP_TENDERLY_ORG_NAME: ${{ secrets.REACT_APP_TENDERLY_ORG_NAME }} | |
REACT_APP_TENDERLY_SIMULATE_ENDPOINT_URL: ${{ secrets.REACT_APP_TENDERLY_SIMULATE_ENDPOINT_URL }} | |
REACT_APP_TENDERLY_PROJECT_NAME: ${{ secrets.REACT_APP_TENDERLY_PROJECT_NAME }} | |
REACT_APP_MMI_BACKEND_BASE_URL: ${{ secrets.MMI_BACKEND_BASE_URL }} | |
REACT_APP_MMI_ENVIRONMENT: ${{ secrets.MMI_ENVIRONMENT }} | |
REACT_APP_WALLETCONNECT_PROJECT_ID: ${{ secrets.REACT_APP_WALLETCONNECT_PROJECT_ID_DEVSTAGING }} | |
REACT_APP_RAMP_APIKEY: ${{ secrets.REACT_APP_RAMP_APIKEY }} | |
# Script to deploy to the dev environment | |
- name: 'Deploy to S3: Develop' | |
if: github.ref == 'refs/heads/development' | |
run: npx nx affected --target=deploy:s3 | |
env: | |
BUCKET_NAME: ${{ secrets.AWS_DEV_BUCKET_NAME }} | |
# Script to deploy to staging environment | |
- name: 'Deploy to S3: Staging' | |
if: github.ref == 'refs/heads/main' | |
run: npx nx affected --base=last-release --target=deploy:s3 | |
env: | |
BUCKET_NAME: ${{ secrets.STAGING_BUCKET_NAME }}/current | |
release: | |
name: Production release | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: main | |
- uses: ./.github/actions/setup-env | |
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 }} | |
- name: 'Deploy production' | |
uses: ./.github/actions/release | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
prod-deployment-hook-token: ${{ secrets.PROD_DEPLOYMENT_HOOK_TOKEN }} | |
prod-deployment-hook-url: ${{ secrets.PROD_DEPLOYMENT_HOOK_URL }} | |
bucket-name: ${{ secrets.STAGING_BUCKET_NAME }}/releases | |
react-app-tenderly-org-name: ${{ secrets.REACT_APP_TENDERLY_ORG_NAME }} | |
react-app-tenderly-project-name: ${{ secrets.REACT_APP_TENDERLY_PROJECT_NAME }} | |
react-app-tenderly-simulate-endpoint-url: ${{ secrets.REACT_APP_TENDERLY_SIMULATE_ENDPOINT_URL }} | |
react-app-mmi-backend-base-url: ${{ secrets.MMI_BACKEND_BASE_URL }} | |
react-app-mmi-environment: ${{ secrets.MMI_ENVIRONMENT }} | |
react-app-walletconnect-project-id: ${{ secrets.REACT_APP_WALLETCONNECT_PROJECT_ID }} | |
react-app-ramp-api: ${{ secrets.REACT_APP_RAMP_APIKEY }} |