Skip to content

Commit

Permalink
ci: disable migration job in staging (#450)
Browse files Browse the repository at this point in the history
- Disables the migration job in staging. OJ migrated data manually in
staging
- Add `!cancelled()` to skip the jobs if we cancel the workflow
  • Loading branch information
arealmaas authored Feb 16, 2024
1 parent 89ec4d7 commit cd99ad3
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 64 deletions.
118 changes: 59 additions & 59 deletions .github/workflows/action-deploy-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,75 +46,75 @@ concurrency:
# if the dryrun input is true, we want to cancel any running deployments in order to not block the pipeline e.g for environment approvals
cancel-in-progress: ${{ inputs.dryRun }}
jobs:
deploy-migration-job:
name: Deploy migration job to ${{ inputs.environment }}
runs-on: ubuntu-latest
# todo: Enabled for staging only. Remove once working in the test environment
if: ${{ inputs.environment == 'staging' }}
environment: ${{inputs.environment}}
permissions:
id-token: write
contents: read
steps:
- name: "Checkout GitHub Action"
uses: actions/checkout@v4
# deploy-migration-job:
# name: Deploy migration job to ${{ inputs.environment }}
# runs-on: ubuntu-latest
# # todo: Enabled for staging only. Remove once working in the test environment
# if: ${{ inputs.environment == 'staging' }}
# environment: ${{inputs.environment}}
# permissions:
# id-token: write
# contents: read
# steps:
# - name: "Checkout GitHub Action"
# uses: actions/checkout@v4

- name: OIDC Login to Azure Public Cloud
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# - name: OIDC Login to Azure Public Cloud
# uses: azure/login@v1
# with:
# client-id: ${{ secrets.AZURE_CLIENT_ID }}
# tenant-id: ${{ secrets.AZURE_TENANT_ID }}
# subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Deploy migration job (${{ inputs.environment }})
uses: azure/arm-deploy@v1
id: deploy
env:
# parameters
IMAGE_TAG: ${{ inputs.gitShortSha }}
# secrets
ADO_CONNECTION_STRING_SECRET_URI: ${{ secrets.AZURE_ADO_CONNECTION_STRING_SECRET_URI }}
CONTAINER_APP_ENVIRONMENT_NAME: ${{ secrets.AZURE_CONTAINER_APP_ENVIRONMENT_NAME }}
with:
scope: resourcegroup
template: ./.azure/applications/web-api-migration-job/main.bicep
resourceGroupName: ${{ secrets.AZURE_RESOURCE_GROUP_NAME }}
deploymentMode: Incremental
deploymentName: "dp-be-${{ inputs.environment }}-web-api-migration-job-${{ inputs.gitShortSha }}"
region: ${{ inputs.region }}
failOnStdErr: false
additionalArguments: "${{inputs.dryRun && '--what-if'}}"
parameters: ./.azure/applications/web-api-migration-job/${{ inputs.environment }}.bicepparam
# - name: Deploy migration job (${{ inputs.environment }})
# uses: azure/arm-deploy@v1
# id: deploy
# env:
# # parameters
# IMAGE_TAG: ${{ inputs.gitShortSha }}
# # secrets
# ADO_CONNECTION_STRING_SECRET_URI: ${{ secrets.AZURE_ADO_CONNECTION_STRING_SECRET_URI }}
# CONTAINER_APP_ENVIRONMENT_NAME: ${{ secrets.AZURE_CONTAINER_APP_ENVIRONMENT_NAME }}
# with:
# scope: resourcegroup
# template: ./.azure/applications/web-api-migration-job/main.bicep
# resourceGroupName: ${{ secrets.AZURE_RESOURCE_GROUP_NAME }}
# deploymentMode: Incremental
# deploymentName: "dp-be-${{ inputs.environment }}-web-api-migration-job-${{ inputs.gitShortSha }}"
# region: ${{ inputs.region }}
# failOnStdErr: false
# additionalArguments: "${{inputs.dryRun && '--what-if'}}"
# parameters: ./.azure/applications/web-api-migration-job/${{ inputs.environment }}.bicepparam

- name: Start migration job
uses: azure/CLI@v1
if: ${{!inputs.dryRun}}
with:
azcliversion: 2.56.0
inlineScript: |
az containerapp job start -n ${{ steps.deploy.outputs.name }} -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }}
# - name: Start migration job
# uses: azure/CLI@v1
# if: ${{!inputs.dryRun}}
# with:
# azcliversion: 2.56.0
# inlineScript: |
# az containerapp job start -n ${{ steps.deploy.outputs.name }} -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }}

- name: Verify migration
uses: azure/CLI@v1
if: ${{!inputs.dryRun}}
id: verify-migration
timeout-minutes: 3
with:
azcliversion: ${{ env.AZ_CLI_VERSION }}
inlineScript: |
./.github/tools/containerAppJobVerifier.sh ${{ steps.deploy.outputs.name }} ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} ${{ inputs.gitShortSha }}
# - name: Verify migration
# uses: azure/CLI@v1
# if: ${{!inputs.dryRun}}
# id: verify-migration
# timeout-minutes: 3
# with:
# azcliversion: ${{ env.AZ_CLI_VERSION }}
# inlineScript: |
# ./.github/tools/containerAppJobVerifier.sh ${{ steps.deploy.outputs.name }} ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} ${{ inputs.gitShortSha }}

- name: Logout from azure
if: ${{failure() || success()}}
continue-on-error: true
run: az logout
# - name: Logout from azure
# if: ${{failure() || success()}}
# continue-on-error: true
# run: az logout

deploy-apps:
name: Deploy ${{ matrix.name }} to ${{ inputs.environment }}
runs-on: ubuntu-latest
# todo: remove once migration job is working in the test environment
if: ${{ always() }}
needs: deploy-migration-job
# if: ${{ always() }}
# needs: deploy-migration-job
strategy:
fail-fast: true
matrix:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci-cd-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
name: Build and publish docker images
uses: ./.github/workflows/action-publish.yml
needs: [generate-git-short-sha, check-for-changes, build-and-test]
if: ${{ always() && !failure() && needs.check-for-changes.outputs.hasBackendChanges == 'true' }}
if: ${{ always() && !failure() && !cancelled() && needs.check-for-changes.outputs.hasBackendChanges == 'true' }}
secrets:
GCR_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -38,7 +38,7 @@ jobs:
deploy-infra-test:
name: Deploy infra to test
needs: [generate-git-short-sha, check-for-changes, publish]
if: ${{ always() && !failure() && needs.check-for-changes.outputs.hasAzureChanges == 'true' }}
if: ${{ always() && !failure() && !cancelled() && needs.check-for-changes.outputs.hasAzureChanges == 'true' }}
uses: ./.github/workflows/action-deploy-infra.yml
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
Expand All @@ -55,7 +55,7 @@ jobs:
deploy-apps-test:
name: Deploy apps to test
needs: [generate-git-short-sha, check-for-changes, deploy-infra-test]
if: ${{ always() && !failure() && needs.check-for-changes.outputs.hasBackendChanges == 'true' }}
if: ${{ always() && !failure() && !cancelled() && needs.check-for-changes.outputs.hasBackendChanges == 'true' }}
uses: ./.github/workflows/action-deploy-apps.yml
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
Expand All @@ -76,7 +76,7 @@ jobs:
deploy-slack-notifier-test:
name: Deploy slack notifier (test)
needs: [check-for-changes, deploy-apps-test]
if: ${{ always() && !failure() && needs.check-for-changes.outputs.hasSlackNotifierChanges == 'true' }}
if: ${{ always() && !failure() && !cancelled() && needs.check-for-changes.outputs.hasSlackNotifierChanges == 'true' }}
uses: ./.github/workflows/action-deploy-function.yml
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
Expand Down Expand Up @@ -127,7 +127,7 @@ jobs:
gitShortSha: ${{ needs.generate-git-short-sha.outputs.gitShortSha }}

dry-run-deploy-apps-staging:
name: Deploy apps to staging
name: Deploy apps to staging (dry run)
needs: [generate-git-short-sha, check-for-changes, deploy-apps-test]
uses: ./.github/workflows/action-deploy-apps.yml
secrets:
Expand Down

0 comments on commit cd99ad3

Please sign in to comment.