From 577a6ec5e6f37f8021dad5d2ad746bc129942c16 Mon Sep 17 00:00:00 2001 From: James Gunn Date: Wed, 30 Oct 2024 17:26:09 +0000 Subject: [PATCH] Refactor deployment workflows (#1638) --- .github/workflows/deploy-dev.yml | 33 ------------- .github/workflows/deploy-prod.yml | 33 ------------- .github/workflows/deploy-test.yml | 33 ------------- .../{deploy-preprod.yml => deploy.yml} | 17 +++---- .github/workflows/main.yml | 48 ++++++++++++++----- .github/workflows/pr.yml | 16 +++++-- 6 files changed, 55 insertions(+), 125 deletions(-) delete mode 100644 .github/workflows/deploy-dev.yml delete mode 100644 .github/workflows/deploy-prod.yml delete mode 100644 .github/workflows/deploy-test.yml rename .github/workflows/{deploy-preprod.yml => deploy.yml} (77%) diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml deleted file mode 100644 index b2729180a..000000000 --- a/.github/workflows/deploy-dev.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Deploy dev environment - -on: - workflow_call: - inputs: - docker_image: - type: string - required: true - - workflow_dispatch: - inputs: - docker_image: - required: true - type: string - -concurrency: deploy_dev -jobs: - deploy_aks: - name: Deploy to AKS - runs-on: ubuntu-latest - - environment: - name: dev - - steps: - - uses: actions/checkout@v4 - - - uses: ./.github/workflows/actions/deploy-aks-environment - id: deploy - with: - environment_name: dev - docker_image: ${{ inputs.docker_image }} - azure_credentials: ${{ secrets.AZURE_CREDENTIALS }} diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml deleted file mode 100644 index 29eaf89e8..000000000 --- a/.github/workflows/deploy-prod.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Deploy production environment - -on: - workflow_call: - inputs: - docker_image: - type: string - required: true - - workflow_dispatch: - inputs: - docker_image: - required: true - type: string - -concurrency: deploy_production -jobs: - deploy_aks: - name: Deploy to AKS - runs-on: ubuntu-latest - - environment: - name: production - - steps: - - uses: actions/checkout@v4 - - - uses: ./.github/workflows/actions/deploy-aks-environment - id: deploy - with: - environment_name: production - docker_image: ${{ inputs.docker_image }} - azure_credentials: ${{ secrets.AZURE_CREDENTIALS }} diff --git a/.github/workflows/deploy-test.yml b/.github/workflows/deploy-test.yml deleted file mode 100644 index db27cebfb..000000000 --- a/.github/workflows/deploy-test.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Deploy test environment - -on: - workflow_call: - inputs: - docker_image: - type: string - required: true - - workflow_dispatch: - inputs: - docker_image: - required: true - type: string - -concurrency: deploy_test -jobs: - deploy_aks: - name: Deploy to AKS - runs-on: ubuntu-latest - - environment: - name: test - - steps: - - uses: actions/checkout@v4 - - - uses: ./.github/workflows/actions/deploy-aks-environment - id: deploy - with: - environment_name: test - docker_image: ${{ inputs.docker_image }} - azure_credentials: ${{ secrets.AZURE_CREDENTIALS }} diff --git a/.github/workflows/deploy-preprod.yml b/.github/workflows/deploy.yml similarity index 77% rename from .github/workflows/deploy-preprod.yml rename to .github/workflows/deploy.yml index c802d6960..878599009 100644 --- a/.github/workflows/deploy-preprod.yml +++ b/.github/workflows/deploy.yml @@ -1,18 +1,15 @@ -name: Deploy pre-production environment +name: Deploy environment on: - workflow_call: - inputs: - docker_image: - type: string - required: true - workflow_dispatch: inputs: docker_image: type: string + environment: + type: environment + required: true -concurrency: deploy_pre-production +concurrency: deploy_${{ inputs.environment }} jobs: package: name: Package application @@ -27,7 +24,7 @@ jobs: runs-on: ubuntu-latest environment: - name: pre-production + name: ${{ inputs.environment }} steps: - uses: actions/checkout@v4 @@ -35,6 +32,6 @@ jobs: - uses: ./.github/workflows/actions/deploy-aks-environment id: deploy with: - environment_name: pre-production + environment_name: ${{ inputs.environment }} docker_image: ${{ inputs.docker_image || needs.package.outputs.docker_image }} azure_credentials: ${{ secrets.AZURE_CREDENTIALS }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3cfa1db2f..4e67b7129 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -51,26 +51,50 @@ jobs: deploy_test: name: Deploy test environment + runs-on: ubuntu-latest needs: [package] - uses: ./.github/workflows/deploy-test.yml - with: - docker_image: ${{ needs.package.outputs.docker_image }} - secrets: inherit + environment: test + concurrency: deploy_test + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/workflows/actions/deploy-aks-environment + id: deploy + with: + environment_name: test + docker_image: ${{ needs.package.outputs.docker_image }} + azure_credentials: ${{ secrets.AZURE_CREDENTIALS }} deploy_preprod: name: Deploy pre-production environment + runs-on: ubuntu-latest needs: [package, deploy_test, check_environments] if: needs.check_environments.outputs.deploy_preprod == 'true' - uses: ./.github/workflows/deploy-preprod.yml - with: - docker_image: ${{ needs.package.outputs.docker_image }} - secrets: inherit + environment: pre-production + concurrency: deploy_pre-production + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/workflows/actions/deploy-aks-environment + id: deploy + with: + environment_name: pre-production + docker_image: ${{ needs.package.outputs.docker_image }} + azure_credentials: ${{ secrets.AZURE_CREDENTIALS }} deploy_prod: name: Deploy production environment + runs-on: ubuntu-latest needs: [deploy_test, package, deploy_preprod] if: always() && (needs.deploy_preprod.result == 'success' || needs.deploy_preprod.result == 'skipped') && (needs.package.result == 'success') && (needs.deploy_test.result == 'success') - uses: ./.github/workflows/deploy-prod.yml - with: - docker_image: ${{ needs.package.outputs.docker_image }} - secrets: inherit + environment: production + concurrency: deploy_production + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/workflows/actions/deploy-aks-environment + id: deploy + with: + environment_name: production + docker_image: ${{ needs.package.outputs.docker_image }} + azure_credentials: ${{ secrets.AZURE_CREDENTIALS }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 4b7afe84e..69f8dde5d 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -173,8 +173,16 @@ jobs: deploy_dev: name: Deploy dev environment + runs-on: ubuntu-latest needs: [lint, validate_terraform, tests, package] - uses: ./.github/workflows/deploy-dev.yml - with: - docker_image: ${{ needs.package.outputs.docker_image }} - secrets: inherit + environment: dev + concurrency: deploy_dev + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/workflows/actions/deploy-aks-environment + id: deploy + with: + environment_name: dev + docker_image: ${{ needs.package.outputs.docker_image }} + azure_credentials: ${{ secrets.AZURE_CREDENTIALS }}