ci: Staging deploy GH action definition (#6455)

* Staging deploy GH action definition

* Remove workflow_dispatch

* Update src/utils/env.ts

Co-authored-by: Zach Pomerantz <zzmp@uniswap.org>

* Restrict sentry reporting to staging environment

* Rename and change environment

---------

Co-authored-by: Zach Pomerantz <zzmp@uniswap.org>
This commit is contained in:
lavalamp 2023-05-10 08:28:59 -04:00 committed by GitHub
parent 82e7925a17
commit 0db9e51e41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 2 deletions

@ -0,0 +1,41 @@
name: Deploy to staging
on:
push:
branches:
- 'releases/staging'
jobs:
deploy-to-staging:
runs-on: ubuntu-latest
environment:
name: staging
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup
- run: yarn prepare
- run: yarn build
env:
REACT_APP_STAGING: 1
- name: Setup node@16 (required by Cloudflare Pages)
uses: actions/setup-node@v3
with:
node-version: 16
- name: Update Cloudflare Pages deployment
uses: cloudflare/pages-action@364c7ca09a4b57837c5967871d64a2c31adb8c0d
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: interface-staging
directory: build
githubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Upload source maps to Sentry
uses: getsentry/action-release@bd5f874fcda966ba48139b0140fb3ec0cb3aabdd
continue-on-error: true
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
with:
environment: staging
sourcemaps: './build/static/js'
url_prefix: '~/static/js'

@ -7,7 +7,7 @@ export function isTestEnv(): boolean {
}
export function isStagingEnv(): boolean {
// This is set in vercel builds.
// This is set in vercel builds and deploys from releases/staging.
return Boolean(process.env.REACT_APP_STAGING)
}
@ -19,9 +19,14 @@ export function isAppUniswapOrg({ hostname }: { hostname: string }): boolean {
return hostname === 'app.uniswap.org'
}
function isAppUniswapStagingOrg({ hostname }: { hostname: string }): boolean {
return hostname === 'app.uniswap-staging.org'
}
export function isSentryEnabled(): boolean {
// Disable in e2e test environments
if (isStagingEnv() || (isProductionEnv() && !isAppUniswapOrg(window.location))) return false
if (isStagingEnv() && !isAppUniswapStagingOrg(window.location)) return false
if (isProductionEnv() && !isAppUniswapOrg(window.location)) return false
return process.env.REACT_APP_SENTRY_ENABLED === 'true'
}