From 5096aa70837982e838fea25d7d71d4b7d658de0e Mon Sep 17 00:00:00 2001 From: Sam Lord Date: Thu, 5 Oct 2023 09:59:32 +0100 Subject: [PATCH] Added a production toggle to build and deploy actions no issue This allows us to disable production builds (since we have no production infrastructure) when tags are pushed. This is especially useful when we're only wanting to build and deploy from a branch for staging during the development, and don't want a production build to override anything. --- .github/workflows/build-image.yml | 6 +++++- .github/workflows/deploy.yml | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 2b05c6d..42c94b2 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -10,6 +10,10 @@ on: description: 'The branch to build for staging deployments' default: main type: string + ENABLE_PRODUCTION: + description: 'Build production images based on tags' + default: true + type: boolean env: STG_PROJECT_ID: stg-pro-397609 @@ -21,7 +25,7 @@ env: jobs: docker: runs-on: ubuntu-latest - if: github.event_name == 'push' && (github.ref == 'refs/heads/${{ inputs.BRANCH }}' || startsWith(github.ref, 'refs/tags/')) + if: github.event_name == 'push' && (github.ref == 'refs/heads/${{ inputs.BRANCH }}' || (${{ inputs.ENABLE_PRODUCTION }} && startsWith(github.ref, 'refs/tags/'))) steps: - name: Set environment (Staging) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c46a329..da93a48 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,6 +10,10 @@ on: description: 'The branch to build for staging deployments' default: main type: string + ENABLE_PRODUCTION: + description: 'Deploy production builds based on tags' + default: true + type: boolean env: STG_PROJECT_ID: stg-pro-397609 @@ -21,7 +25,7 @@ env: jobs: docker: runs-on: ubuntu-latest - if: github.event_name == 'push' && (github.ref == 'refs/heads/${{ inputs.BRANCH }}' || startsWith(github.ref, 'refs/tags/')) + if: github.event_name == 'push' && (github.ref == 'refs/heads/${{ inputs.BRANCH }}' || (${{ inputs.ENABLE_PRODUCTION }} && startsWith(github.ref, 'refs/tags/'))) steps: - name: Set environment (Staging)