Skip to content

Commit

Permalink
Merge branch 'main' into cent-app/cfg-evm-transfer-support
Browse files Browse the repository at this point in the history
  • Loading branch information
sophialittlejohn authored Dec 5, 2023
2 parents 8ebe91f + e9fb0e2 commit 03770b7
Show file tree
Hide file tree
Showing 24 changed files with 257 additions and 134 deletions.
4 changes: 0 additions & 4 deletions .github/actions/deploy-gfunction/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ inputs:
deploy_env:
description: env to deploy function to
required: false

checkout_path:
description: Folder with repository code
required: true

GWIP:
description: Google Workflow Identity provider
Expand Down
49 changes: 27 additions & 22 deletions .github/actions/prepare-deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ inputs:
description: "app name you're deploying"
required: true
deploy_to:
description: "(Optional) Manual trigger to deploy"
description: '(Optional) Manual trigger to deploy'
required: false
outputs:
function_name:
description: "App name with environment appended"
function_name:
description: 'App name with environment appended'
value: ${{ steps.naming.outputs.function_name}}
front_url:
description: "Full URL for your front-end piece"
front_url:
description: 'Full URL for your front-end piece'
value: ${{ steps.naming.outputs.front_url }}
gh_env:
description: "Github actions environment to use for deployment"
value: ${{ steps.setenv.outputs.gh_env }}
env_name:
description: "Name of environment to deploy to"
value: ${{ steps.naming.outputs.env_name }}
gh_env:
description: 'Github actions environment to use for deployment'
value: ${{ steps.setenv.outputs.gh_env }}
env_name:
description: 'Name of environment to deploy to'
value: ${{ steps.naming.outputs.env_name }}

runs:
using: composite
Expand All @@ -35,13 +35,13 @@ runs:
contains(inputs.deploy_to, 'staging') ||
contains(inputs.deploy_to, 'production') }}; then
echo "gh_env=production" >> $GITHUB_OUTPUT
fi
fi
- name: Set artifact names based on environment
id: naming
shell: bash
# Follow deployment strategy from
# https://centrifuge.hackmd.io/MFsnRldyQSa4cadx11OtVg?both#Environments
# Follow deployment strategy from
# https://centrifuge.hackmd.io/MFsnRldyQSa4cadx11OtVg?both#Environments
run: |
echo "Set app name based on env strategy"
if ${{ inputs.deploy_to == 'production' }}; then
Expand All @@ -63,32 +63,37 @@ runs:
elif ${{ inputs.deploy_to == 'catalyst' }}; then
# CATALYST
echo "function_name=${{ inputs.app_base_name }}-catalyst" >> $GITHUB_OUTPUT
echo "front_url=${{ inputs.app_base_name }}-catalyst.k-f.dev" >> $GITHUB_OUTPUT
echo "front_url=app-catalyst.k-f.dev" >> $GITHUB_OUTPUT
echo "env_name=catalyst" >> $GITHUB_OUTPUT
elif ${{ contains(inputs.deploy_to, 'demo') }}; then
elif ${{ inputs.deploy_to == 'demo' }}; then
# DEMO
echo "function_name=${{ inputs.app_base_name }}-demo" >> $GITHUB_OUTPUT
echo "front_url=${{ inputs.app_base_name }}-demo.k-f.dev" >> $GITHUB_OUTPUT
echo "front_url=app-demo.k-f.dev" >> $GITHUB_OUTPUT
echo "env_name=demo" >> $GITHUB_OUTPUT
elif ${{ inputs.deploy_to == 'ff-prod' }}; then
# FF-PRODUCTION
# A build from the DEV env that points to prod
echo "function_name=${{ inputs.app_base_name }}-ff-production" >> $GITHUB_OUTPUT
echo "front_url=app-ff-production.k-f.dev" >> $GITHUB_OUTPUT
echo "env_name=production" >> $GITHUB_OUTPUT
elif ${{ github.ref == 'refs/heads/main' }}; then
# DEV
echo "function_name=${{ inputs.app_base_name }}-dev" >> $GITHUB_OUTPUT
echo "front_url=${{ inputs.app_base_name }}-dev.k-f.dev" >> $GITHUB_OUTPUT
echo "env_name=development" >> $GITHUB_OUTPUT
echo "front_url=app-dev.k-f.dev" >> $GITHUB_OUTPUT
echo "env_name=development" >> $GITHUB_OUTPUT
elif ${{ github.event_name == 'pull_request' }}; then
# PR
echo "function_name=${{ inputs.app_base_name }}-pr${{ github.event.number }}" >> $GITHUB_OUTPUT
echo "front_url=${{ inputs.app_base_name }}-pr${{ github.event.number }}.k-f.dev" >> $GITHUB_OUTPUT
echo "front_url=app-pr${{ github.event.number }}.k-f.dev" >> $GITHUB_OUTPUT
echo "env_name=development" >> $GITHUB_OUTPUT
else
echo "::error title=No env to deploy::Workflow called from non-deployable branch/tag"
fi
- name: debug outputs
shell: bash
run: |
echo "URL ${{ steps.naming.outputs.front_url }}"
echo "App name: ${{ steps.naming.outputs.function_name }}"
echo "Env name: ${{ steps.naming.outputs.env_name }}"
echo "GH env: ${{ steps.setenv.outputs.gh_env }}"
21 changes: 9 additions & 12 deletions .github/workflows/centrifuge-app.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
name: Centrifuge App
on:
push:
branches:
- main
paths:
- 'centrifuge-app/**'
- 'centrifuge-js/**'
- 'centrifuge-react/**'
- '.github/workflows/centrifuge-app.yml'
- '.github/actions/deploy-gcs'
pull_request:
paths:
- 'centrifuge-app/**'
Expand All @@ -23,7 +14,7 @@ on:
required: false
# Fancy concurrency group string to allow for multi-staging deployments
concurrency:
group: 'centrifuge-app-${{ inputs.deploy_env || github.event.inputs.deploy_env }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
group: 'centrifuge-app-${{ inputs.deploy_env || github.event.inputs.deploy_env }}@${{ github.event.name }}${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
env:
artifact_name: "webpack${{ inputs.deploy_env && format('-{0}', inputs.deploy_env) }}"
Expand Down Expand Up @@ -103,7 +94,7 @@ jobs:
deploy-app:
concurrency:
# Do not sync the same bucket in parallel
group: deploy-${{ needs.build-app.outputs.front_url }}
group: deploy-${{ needs.build-app.outputs.front_url }}-${{ github.event.name }}
cancel-in-progress: true
permissions:
contents: 'read'
Expand Down Expand Up @@ -138,17 +129,23 @@ jobs:
if: github.event_name == 'pull_request'
steps:
- name: PR comment with preview URL
id: prcomment
uses: thollander/actions-comment-pull-request@v2
env:
pull_sha: ${{ github.event.pull_request.head.sha }}
with:
comment_tag: pr_preview_url
mode: recreate
message: |
PR deployed in Google Cloud
URL: https://${{ needs.deploy-app.outputs.bucket_url }}
Commit #: ${{ env.pull_sha }}
To access the functions directly check the corresponding deploy Action
- name: Check notify outputs
run: |
echo "id : ${{ steps.prcomment.outputs.id }}"
echo "body : ${{ steps.prcomment.outputs.body }}"
echo "html_url : ${{ steps.prcomment.outputs.html_url }}"
# owasp_scan:
# needs: deploy-app
# runs-on: ubuntu-latest
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/deploy_all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "Deploy all apps"
on:
# Allow this wofkflow as a universal "deployer" to
# call from other workflows.
workflow_call:
inputs:
environment:
required: true
type: string

jobs:
app:
name: webapp
uses: ./.github/workflows/centrifuge-app.yml
secrets: inherit
with:
deploy_env: ${{ inputs.environment}}


pinning:
if: ${{ inputs.environment != 'ff-prod' }}
name: pinning
uses: ./.github/workflows/pinning-api.yml
secrets: inherit
with:
deploy_env: ${{ inputs.environment }}


onboarding:
if: ${{ inputs.environment != 'ff-prod' }}
name: onboarding
uses: ./.github/workflows/onboarding-api.yml
secrets: inherit
with:
deploy_env: ${{ inputs.environment}}

faucet:
if: ${{ inputs.environment == 'demo' || inputs.environment == 'development' }}
name: faucet
uses: ./.github/workflows/faucet-api.yml
secrets: inherit
with:
deploy_env: ${{ inputs.environment}}
19 changes: 5 additions & 14 deletions .github/workflows/faucet-api.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
name: Faucet API
on:
push:
branches:
- main
paths:
- 'faucet-api/**'
- '.github/workflows/faucet-api.yml'
- '.github/actions/deploy-gfunction'
- '.github/actions/build-function'
pull_request:
paths:
- 'faucet-api/**'
Expand All @@ -19,15 +11,11 @@ on:
deploy_env:
type: string
required: false
default: demo
env:
app_name: faucet-api
# For now deploy only on demo when triggered with workflow_call:
deploy_to: ${{ inputs.deploy_env && 'demo' || '' }}
# deploy_to: ${{ inputs_deploy_env }}
function_handler: faucet
concurrency:
group: 'faucet-api@${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
group: 'faucet-api-${{ inputs.deploy_env || github.event.inputs.deploy_env }}@${{ github.event.name }}${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
Expand Down Expand Up @@ -57,6 +45,9 @@ jobs:
function_name: ${{ steps.prepare.outputs.function_name }}

deploy-faucet:
# if: ${{ inputs.deploy_env == 'demo' }} || ${{ inputs.deploy_env == 'development' }}
# For now deploy only to demo
if: ${{ inputs.deploy_env == 'demo' }}
concurrency:
group: deploy-${{ needs.build-faucet.outputs.function_name }}
cancel-in-progress: false
Expand All @@ -82,4 +73,4 @@ jobs:
target: ${{ env.function_handler }}
gcloud_region: ${{ vars.GCLOUD_REGION }}
service_account: '${{ vars.FIRESTORE_SA }}'
deploy_env: ${{ env.deploy_to }}
deploy_env: ${{ inputs.deploy_env }}
18 changes: 18 additions & 0 deletions .github/workflows/main-branch-deploys.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: deploy-main
on:
push:
branches: main
pull_request:
paths:
- '.github/workflows/main-branch-deploys.yml'

jobs:
trigger:
name: deploy-${{ matrix.env }}
strategy:
matrix:
env: ['ff-prod', 'development']
uses: ./.github/workflows/deploy_all.yml
secrets: inherit
with:
environment: ${{ matrix.env }}
17 changes: 17 additions & 0 deletions .github/workflows/manual-deploys.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Deploy to Catalyst and demo
on:
workflow_dispatch:
inputs:
environment:
type: choice
description: where to deploy
options:
- demo
- catalyst
jobs:
deploy:
name: deploy-${{ inputs.environment }}
uses: ./.github/workflows/deploy_all.yml
secrets: inherit
with:
environment: ${{ inputs.environment }}
12 changes: 2 additions & 10 deletions .github/workflows/onboarding-api.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
name: Onboarding API
on:
push:
branches:
- main
paths:
- 'onboarding-api/**'
- '.github/workflows/onboarding-api.yml'
- '.github/actions/deploy-gfunction'
- '.github/actions/build-function'
pull_request:
paths:
- 'onboarding-api/**'
Expand All @@ -26,7 +18,7 @@ env:
artifact_name: "onboarding-api${{ inputs.deploy_env && format('-{0}', inputs.deploy_env) }}"
concurrency:
# Fancy concurrency group string to allow for multi-staging deployments
group: 'onboarding-api-${{ inputs.deploy_env || github.event.inputs.deploy_env }} @${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
group: 'onboarding-api-${{ inputs.deploy_env || github.event.inputs.deploy_env }}@${{ github.event.name }}${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
Expand Down Expand Up @@ -69,7 +61,7 @@ jobs:
deploy-onboarding-api:
concurrency:
# Don't try to deploy the same function in parallel
group: deploy-${{ needs.build-onboarding-api.outputs.function_name }}
group: deploy-${{ needs.build-onboarding-api.outputs.function_name }}-${{ github.event.name}}
cancel-in-progress: true
needs: build-onboarding-api
runs-on: ubuntu-latest
Expand Down
16 changes: 4 additions & 12 deletions .github/workflows/pinning-api.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
name: Pinning API
on:
push:
branches:
- main
paths:
- 'pinning-api/**'
- '.github/workflows/pinning-api.yml'
- '.github/actions/deploy-gfunction'
- '.github/actions/build-function'
pull_request:
paths:
- 'pinning-api/**'
Expand All @@ -26,7 +18,7 @@ env:
artifact_name: "pinning-api${{ inputs.deploy_env && format('-{0}', inputs.deploy_env) }}"
concurrency:
# Fancy concurrency group string to allow for multi-staging deployments
group: 'pinning-api-${{ inputs.deploy_env || github.event.inputs.deploy_env }} @${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
group: 'pinning-api-${{ inputs.deploy_env || github.event.inputs.deploy_env }}@${{ github.event.name }}${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
build-pinning-api:
Expand All @@ -51,7 +43,7 @@ jobs:
uses: ./.github/actions/build-function
with:
app_name: ${{ env.app_name }}
artifact_name: ${{ env.artifact_name }}
artifact_name: ${{ steps.prepare.outputs.function_name }}

- name: Archive staging artifacts
id: archive_staging
Expand All @@ -68,7 +60,7 @@ jobs:
deploy-pinning-api:
concurrency:
# Don't try to deploy the same function in parallel
group: deploy-${{ needs.build-pinning-api.outputs.function_name }}
group: deploy-${{ needs.build-pinning-api.outputs.function_name }}-${{ github.event.name }}
cancel-in-progress: true
needs: build-pinning-api
runs-on: ubuntu-latest
Expand All @@ -87,7 +79,7 @@ jobs:
uses: ./apps/.github/actions/deploy-gfunction
with:
app_name: ${{ env.app_name }}
artifact_name: ${{ env.artifact_name }}
artifact_name: ${{ needs.build-pinning-api.outputs.function_name }}
GWIP: ${{ secrets.GWIP }}
GSA: ${{ secrets.GSA }}
target: ${{ env.function_handler }}
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/.env-config/.env.altair
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ REACT_APP_WHITELISTED_ACCOUNTS=
REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kovan-staging/latest.json
REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=kALJqPUHFzDR2VkoQYWefPQyzjGzKznNny2smXGQpSf3aMw19
REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a
REACT_APP_TINLAKE_SUBGRAPH_URL=https://api.goldsky.com/api/public/project_clhi43ef5g4rw49zwftsvd2ks/subgraphs/main/1.0.2/gn
REACT_APP_TINLAKE_SUBGRAPH_URL=https://api.goldsky.com/api/public/project_clhi43ef5g4rw49zwftsvd2ks/subgraphs/main/prod/gn
2 changes: 1 addition & 1 deletion centrifuge-app/.env-config/.env.catalyst
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ REACT_APP_WHITELISTED_ACCOUNTS=
REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kovan-staging/latest.json
REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=4bo2vNkwZtr2PuqppWwqya6dPC8MzxqZ4kgnAoTZyKo9Kxq8
REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a
REACT_APP_TINLAKE_SUBGRAPH_URL=https://api.goldsky.com/api/public/project_clhi43ef5g4rw49zwftsvd2ks/subgraphs/main/1.0.2/gn
REACT_APP_TINLAKE_SUBGRAPH_URL=https://api.goldsky.com/api/public/project_clhi43ef5g4rw49zwftsvd2ks/subgraphs/main/prod/gn
Loading

0 comments on commit 03770b7

Please sign in to comment.