Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions .github/actions/unify-services/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
107 changes: 53 additions & 54 deletions .github/workflows/main-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
Expand All @@ -88,64 +88,63 @@ 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 }}
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 }}

force_new_deployment: ${{ inputs.force_new_deployment }}

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) }}
Expand All @@ -157,19 +156,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: ${{ matrix.force_new_deployment || true }}
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 }}