diff --git a/.github/actions/deploy-gfunction/action.yml b/.github/actions/deploy-gfunction/action.yml index b566939cfd..1f8d271062 100644 --- a/.github/actions/deploy-gfunction/action.yml +++ b/.github/actions/deploy-gfunction/action.yml @@ -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 diff --git a/.github/actions/prepare-deploy/action.yml b/.github/actions/prepare-deploy/action.yml index 490b0bb75b..1e76509660 100644 --- a/.github/actions/prepare-deploy/action.yml +++ b/.github/actions/prepare-deploy/action.yml @@ -63,27 +63,33 @@ 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 ${{ contains(inputs.deploy_to, 'moonbeam-alpha') }}; then + elif ${{ inputs.deploy_to == 'moonbeam-alpha' }}; then # moonbeam-alpha echo "function_name=${{ inputs.app_base_name }}-moonbeam-alpha" >> $GITHUB_OUTPUT - echo "front_url=${{ inputs.app_base_name }}-moonbeam-alpha.k-f.dev" >> $GITHUB_OUTPUT + echo "front_url=app-moonbeam-alpha.k-f.dev" >> $GITHUB_OUTPUT echo "env_name=moonbeam-alpha" >> $GITHUB_OUTPUT - elif ${{ github.ref == 'refs/heads/main' }}; then + elif ${{ inputs.deploy_to == 'development' }}; 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 ${{ 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.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" diff --git a/.github/workflows/catalyst-deploy.yml b/.github/workflows/catalyst-deploy.yml deleted file mode 100644 index 3c6d323231..0000000000 --- a/.github/workflows/catalyst-deploy.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Deploy Catalyst -on: - push: - tags: - - "centrifuge-app/v*" -concurrency: - # Cancel any staging or prod deployment on-going - # in favor of this new pre-release - group: catalyst-deployment - cancel-in-progress: true - -jobs: - app-staging: - uses: ./.github/workflows/centrifuge-app.yml - secrets: inherit - with: - deploy_env: catalyst - - - pinning-staging: - uses: ./.github/workflows/pinning-api.yml - secrets: inherit - with: - deploy_env: catalyst - - - onboarding-staging: - uses: ./.github/workflows/onboarding-api.yml - secrets: inherit - with: - deploy_env: catalyst \ No newline at end of file diff --git a/.github/workflows/centrifuge-app.yml b/.github/workflows/centrifuge-app.yml index 27940baf40..af5801bfb5 100644 --- a/.github/workflows/centrifuge-app.yml +++ b/.github/workflows/centrifuge-app.yml @@ -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/**' @@ -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) }}" @@ -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' diff --git a/.github/workflows/demo-deploys.yml b/.github/workflows/demo-deploys.yml deleted file mode 100644 index b0ef1ef426..0000000000 --- a/.github/workflows/demo-deploys.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: "Demo deployments (manual)" -on: - workflow_dispatch: - -jobs: - app-demo: - uses: ./.github/workflows/centrifuge-app.yml - secrets: inherit - with: - deploy_env: demo - - - pinning-demo: - uses: ./.github/workflows/pinning-api.yml - secrets: inherit - with: - deploy_env: demo - - - onboarding-demo: - uses: ./.github/workflows/onboarding-api.yml - secrets: inherit - with: - deploy_env: demo - - faucet-demo: - uses: ./.github/workflows/faucet-api.yml - secrets: inherit - with: - deploy_env: demo \ No newline at end of file diff --git a/.github/workflows/deploy_all.yml b/.github/workflows/deploy_all.yml new file mode 100644 index 0000000000..54d07b73db --- /dev/null +++ b/.github/workflows/deploy_all.yml @@ -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}} \ No newline at end of file diff --git a/.github/workflows/faucet-api.yml b/.github/workflows/faucet-api.yml index 42f2b7f483..158472b6fe 100644 --- a/.github/workflows/faucet-api.yml +++ b/.github/workflows/faucet-api.yml @@ -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/**' @@ -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: @@ -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 @@ -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 }} diff --git a/.github/workflows/main-branch-deploys.yml b/.github/workflows/main-branch-deploys.yml new file mode 100644 index 0000000000..656a080dfe --- /dev/null +++ b/.github/workflows/main-branch-deploys.yml @@ -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: ['moonbeam-alpha', 'ff-prod', 'development'] + uses: ./.github/workflows/deploy_all.yml + secrets: inherit + with: + environment: ${{ matrix.env }} \ No newline at end of file diff --git a/.github/workflows/manual-deploys.yml b/.github/workflows/manual-deploys.yml new file mode 100644 index 0000000000..c7985a3b7d --- /dev/null +++ b/.github/workflows/manual-deploys.yml @@ -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 }} \ No newline at end of file diff --git a/.github/workflows/moonbeam-alpha-deploy.yml b/.github/workflows/moonbeam-alpha-deploy.yml deleted file mode 100644 index 16f0014455..0000000000 --- a/.github/workflows/moonbeam-alpha-deploy.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: "Moonbeam dev (alpha) deployments (manual)" -on: - push: - branches: main - pull_request: - paths: - - '.github/workflows/moonbeam-alpha-deploy.yml' - -jobs: - app-moonbeam-alpha: - uses: ./.github/workflows/centrifuge-app.yml - secrets: inherit - with: - deploy_env: moonbeam-alpha - - - pinning-moonbeam-alpha: - uses: ./.github/workflows/pinning-api.yml - secrets: inherit - with: - deploy_env: moonbeam-alpha - - - onboarding-moonbeam-alpha: - uses: ./.github/workflows/onboarding-api.yml - secrets: inherit - with: - deploy_env: moonbeam-alpha - - # faucet-moonbeam-alpha: - # uses: ./.github/workflows/faucet-api.yml - # secrets: inherit - # with: - # deploy_env: moonbeam-alpha \ No newline at end of file diff --git a/.github/workflows/onboarding-api.yml b/.github/workflows/onboarding-api.yml index 55b2c36e9d..9fabfe8e40 100644 --- a/.github/workflows/onboarding-api.yml +++ b/.github/workflows/onboarding-api.yml @@ -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/**' @@ -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: @@ -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 diff --git a/.github/workflows/pinning-api.yml b/.github/workflows/pinning-api.yml index a1808e49fe..5ade412031 100644 --- a/.github/workflows/pinning-api.yml +++ b/.github/workflows/pinning-api.yml @@ -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/**' @@ -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: @@ -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 @@ -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 @@ -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 }}