From c718b33227a70e11b2f9759d45d2210755fb028d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andri=20Mar=20Bj=C3=B6rgvinsson?= Date: Thu, 8 Jan 2026 09:16:15 +0000 Subject: [PATCH 1/4] feat: Allow configuration on service level if we should force new deployment --- .github/workflows/main-deploy.yml | 104 +++++++++++++++--------------- 1 file changed, 51 insertions(+), 53 deletions(-) diff --git a/.github/workflows/main-deploy.yml b/.github/workflows/main-deploy.yml index 72d755b..9da4080 100644 --- a/.github/workflows/main-deploy.yml +++ b/.github/workflows/main-deploy.yml @@ -34,27 +34,27 @@ on: required: false type: string terraform_version: - description: 'Terraform version' + description: "Terraform version" type: string - default: '1.9.8' + default: "1.9.8" working_directory: - description: 'Working directory' + description: "Working directory" type: string - default: '.' + default: "." build_checkout_with_lfs: - description: 'Checkout with LFS' + description: "Checkout with LFS" type: boolean default: false use_latest_tag: - description: 'Use latest tag' + description: "Use latest tag" type: boolean default: true pre_applied_resources: - description: 'Resources to apply before main deploy' + description: "Resources to apply before main deploy" type: string - default: '[]' + default: "[]" force_new_deployment: - description: 'Force a new deployment even if the image tag is the same as the current deployment. E.g. latest' + description: "Force a new deployment even if the image tag is the same as the current deployment. E.g. latest" type: boolean default: true secrets: @@ -67,7 +67,7 @@ permissions: jobs: terraform-quality-checks: - name: '✅ Terraform Quality checks' + name: "✅ Terraform Quality checks" uses: aproorg/github-workflows/.github/workflows/terraform-quality-checks.yml@main with: terraform_version: ${{ inputs.terraform_version }} @@ -88,7 +88,7 @@ jobs: github_token: ${{ secrets.token }} unify-services: - name: '🤝 Unify service inputs' + name: "🤝 Unify service inputs" runs-on: ubuntu-latest outputs: final_services: ${{ steps.unify-services.outputs.final_services }} @@ -100,52 +100,50 @@ jobs: service_name: ${{ inputs.service_name }} services: ${{ inputs.services }} - create-ecr-repo: - name: '🚀 Apply shared' + name: "🚀 Apply shared" needs: unify-services strategy: matrix: include: ${{ fromJSON(needs.unify-services.outputs.final_services) }} runs-on: ubuntu-latest steps: - - name: 📁 Checkout - uses: actions/checkout@v4 + - name: 📁 Checkout + uses: actions/checkout@v4 - - name: '🚀 Apply shared' - uses: aproorg/github-workflows/.github/actions/apply-shared@main - with: - AWS_REGION: ${{ inputs.aws_region }} - AWS_ECR_DEPLOYMENT_ROLE: ${{ inputs.github_ci_ecr_role_arn }} - TERRAFORM_VERSION: ${{ inputs.terraform_version }} - TERRAFORM_PATH: '${{ matrix.directory }}/terraform' + - name: "🚀 Apply shared" + uses: aproorg/github-workflows/.github/actions/apply-shared@main + with: + AWS_REGION: ${{ inputs.aws_region }} + AWS_ECR_DEPLOYMENT_ROLE: ${{ inputs.github_ci_ecr_role_arn }} + TERRAFORM_VERSION: ${{ inputs.terraform_version }} + TERRAFORM_PATH: "${{ matrix.directory }}/terraform" build-and-push-all-images: - name: '️️️🏗️ Build and push all images' + name: "️️️🏗️ Build and push all images" needs: - terraform-quality-checks - get-next-version if: ${{ needs.get-next-version.outputs.new_release_published == 'true' }} runs-on: ubuntu-latest steps: - - name: 📁 Checkout - uses: actions/checkout@v4 - with: - lfs: ${{ inputs.build_checkout_with_lfs }} - - - name: '️️️🏗️ Build and push image all images' - uses: aproorg/github-workflows/.github/actions/build-and-push-image@main - with: - AWS_REGION: ${{ inputs.aws_region }} - AWS_ROLE_ARN: ${{ inputs.github_ci_ecr_role_arn }} - WORKING_DIRECTORY: ${{ inputs.working_directory }} - ECR_REPOSITORY: ${{ inputs.ecr_repository }} - ECR_REPOSITORIES: ${{ inputs.ecr_repositories }} - CUSTOM_BUILD_SCRIPT: ${{ inputs.custom_build_script }} + - name: 📁 Checkout + uses: actions/checkout@v4 + with: + lfs: ${{ inputs.build_checkout_with_lfs }} + - name: "️️️🏗️ Build and push image all images" + uses: aproorg/github-workflows/.github/actions/build-and-push-image@main + with: + AWS_REGION: ${{ inputs.aws_region }} + AWS_ROLE_ARN: ${{ inputs.github_ci_ecr_role_arn }} + WORKING_DIRECTORY: ${{ inputs.working_directory }} + ECR_REPOSITORY: ${{ inputs.ecr_repository }} + ECR_REPOSITORIES: ${{ inputs.ecr_repositories }} + CUSTOM_BUILD_SCRIPT: ${{ inputs.custom_build_script }} deploy-to-dev: - name: '🚀 Deploy to dev' + name: "🚀 Deploy to dev" strategy: matrix: include: ${{ fromJSON(needs.unify-services.outputs.final_services) }} @@ -157,19 +155,19 @@ jobs: if: ${{ needs.get-next-version.outputs.new_release_published == 'true' }} runs-on: ubuntu-latest steps: - - name: 📁 Checkout - uses: actions/checkout@v4 + - name: 📁 Checkout + uses: actions/checkout@v4 - - name: '🚀 Deploy to dev' - uses: aproorg/github-workflows/.github/actions/deploy-ecs-service@main - with: - AWS_REGION: ${{ inputs.aws_region }} - ENVIRONMENT: dev - AWS_DEPLOYMENT_ROLE: ${{ inputs.github_ci_role_arn }} - IMAGE_TAG: ${{ inputs.use_latest_tag && 'latest' || format('sha-{0}', github.sha) }} - FORCE_NEW_DEPLOYMENT: ${{ inputs.force_new_deployment }} - SERVICE_NAME: ${{ matrix.name }} - CLUSTER_NAME: ${{ inputs.cluster_name }} - TERRAFORM_VERSION: ${{ inputs.terraform_version }} - TERRAFORM_PATH: '${{ matrix.directory }}/terraform' - PRE_APPLIED_RESOURCES: ${{ inputs.pre_applied_resources }} + - name: "🚀 Deploy to dev" + uses: aproorg/github-workflows/.github/actions/deploy-ecs-service@main + with: + AWS_REGION: ${{ inputs.aws_region }} + ENVIRONMENT: dev + AWS_DEPLOYMENT_ROLE: ${{ inputs.github_ci_role_arn }} + IMAGE_TAG: ${{ inputs.use_latest_tag && 'latest' || format('sha-{0}', github.sha) }} + FORCE_NEW_DEPLOYMENT: ${{ inputs.force_new_deployment || matrix.force_new_deployment }} + SERVICE_NAME: ${{ matrix.name }} + CLUSTER_NAME: ${{ inputs.cluster_name }} + TERRAFORM_VERSION: ${{ inputs.terraform_version }} + TERRAFORM_PATH: "${{ matrix.directory }}/terraform" + PRE_APPLIED_RESOURCES: ${{ inputs.pre_applied_resources }} From 7a1df75c5ce81106aca30f562b6e9c6c5bdf4e39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andri=20Mar=20Bj=C3=B6rgvinsson?= Date: Thu, 8 Jan 2026 11:32:30 +0000 Subject: [PATCH 2/4] Use unify to set the force new deployment to false --- .github/actions/unify-services/action.yml | 23 +++++++++++++---------- .github/workflows/main-deploy.yml | 3 ++- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/actions/unify-services/action.yml b/.github/actions/unify-services/action.yml index 4fe9b37..34ecd1c 100644 --- a/.github/actions/unify-services/action.yml +++ b/.github/actions/unify-services/action.yml @@ -9,6 +9,9 @@ inputs: services: description: Multiple services (JSON array of objects) required: false + force_new_deployment: + description: Whether to force a new deployment + required: false outputs: final_services: @@ -22,13 +25,13 @@ runs: id: unify-services shell: bash run: | - if [ -n "${{ inputs.service_name }}" ] && [ -z "${{ inputs.services }}" ]; then - echo 'final_services=[{"directory":".","name":"${{ inputs.service_name }}"}]' >> $GITHUB_OUTPUT - - elif [ -z "${{ inputs.service_name }}" ] && [ -n "${{ inputs.services }}" ]; then - echo 'final_services=${{ inputs.services }}' >> $GITHUB_OUTPUT - - else - echo "ERROR: Exactly one of 'service_name' or 'services' must be set." >&2 - exit 1 - fi + if [ -n "${{ inputs.service_name }}" ] && [ -z "${{ inputs.services }}" ]; then + echo 'final_services=[{"directory":".","name":"${{ inputs.service_name }}","force_new_deployment":"${{ inputs.force_new_deployment }}"}]' >> $GITHUB_OUTPUT + + elif [ -z "${{ inputs.service_name }}" ] && [ -n "${{ inputs.services }}" ]; then + echo 'final_services=${{ inputs.services }}' >> $GITHUB_OUTPUT + + else + echo "ERROR: Exactly one of 'service_name' or 'services' must be set." >&2 + exit 1 + fi diff --git a/.github/workflows/main-deploy.yml b/.github/workflows/main-deploy.yml index 9da4080..9c3a3e0 100644 --- a/.github/workflows/main-deploy.yml +++ b/.github/workflows/main-deploy.yml @@ -99,6 +99,7 @@ jobs: with: service_name: ${{ inputs.service_name }} services: ${{ inputs.services }} + force_new_deployment: ${{ inputs.force_new_deployment }} create-ecr-repo: name: "🚀 Apply shared" @@ -165,7 +166,7 @@ jobs: ENVIRONMENT: dev AWS_DEPLOYMENT_ROLE: ${{ inputs.github_ci_role_arn }} IMAGE_TAG: ${{ inputs.use_latest_tag && 'latest' || format('sha-{0}', github.sha) }} - FORCE_NEW_DEPLOYMENT: ${{ inputs.force_new_deployment || matrix.force_new_deployment }} + FORCE_NEW_DEPLOYMENT: ${{ matrix.force_new_deployment }} SERVICE_NAME: ${{ matrix.name }} CLUSTER_NAME: ${{ inputs.cluster_name }} TERRAFORM_VERSION: ${{ inputs.terraform_version }} From 31bb95e9675eba868456c914aa3866a4a17a0689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andri=20Mar=20Bj=C3=B6rgvinsson?= Date: Thu, 8 Jan 2026 13:01:03 +0000 Subject: [PATCH 3/4] Using the branch --- .github/workflows/main-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main-deploy.yml b/.github/workflows/main-deploy.yml index 9c3a3e0..963ea0d 100644 --- a/.github/workflows/main-deploy.yml +++ b/.github/workflows/main-deploy.yml @@ -95,7 +95,7 @@ jobs: steps: - name: 🤝 Unify service inputs id: unify-services - uses: aproorg/github-workflows/.github/actions/unify-services@main + uses: aproorg/github-workflows/.github/actions/unify-services@services-force-deployment-configuration with: service_name: ${{ inputs.service_name }} services: ${{ inputs.services }} From c4abbd777765ba6f48e37abfcce37c85469ce9b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andri=20Mar=20Bj=C3=B6rgvinsson?= Date: Thu, 8 Jan 2026 13:23:57 +0000 Subject: [PATCH 4/4] Seting or opperator for default true value --- .github/workflows/main-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main-deploy.yml b/.github/workflows/main-deploy.yml index 963ea0d..71c1b28 100644 --- a/.github/workflows/main-deploy.yml +++ b/.github/workflows/main-deploy.yml @@ -166,7 +166,7 @@ jobs: ENVIRONMENT: dev AWS_DEPLOYMENT_ROLE: ${{ inputs.github_ci_role_arn }} IMAGE_TAG: ${{ inputs.use_latest_tag && 'latest' || format('sha-{0}', github.sha) }} - FORCE_NEW_DEPLOYMENT: ${{ matrix.force_new_deployment }} + FORCE_NEW_DEPLOYMENT: ${{ matrix.force_new_deployment || true }} SERVICE_NAME: ${{ matrix.name }} CLUSTER_NAME: ${{ inputs.cluster_name }} TERRAFORM_VERSION: ${{ inputs.terraform_version }}