From 998454fc9e583c8e20ef1f47d52a830bd0b5fd9a Mon Sep 17 00:00:00 2001 From: Stefan Hattrell <29941279+digorgonzola@users.noreply.github.com> Date: Tue, 13 Feb 2024 14:18:41 +1100 Subject: [PATCH] github workflows: update with more generic parameters --- .github/workflows/build-production.yml | 8 ++++---- .github/workflows/build-staging.yml | 12 +++++++----- .github/workflows/test.yml | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index b7718d6..f94dd1f 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -10,14 +10,13 @@ permissions: contents: read env: + app_name: sample-django-app environment_name: production jobs: build_push: runs-on: ubuntu-latest environment: production - outputs: - image_digest: ${{ steps.build_and_push.outputs.digest }} steps: - name: Checkout uses: actions/checkout@v4 @@ -29,6 +28,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Configure AWS Credentials + id: aws_auth uses: aws-actions/configure-aws-credentials@v4 with: audience: sts.amazonaws.com @@ -53,7 +53,7 @@ jobs: - name: Push Image Digest to SSM run: | aws ssm put-parameter \ - --name "/apps/sample-django-app/${{ env.environment_name }}/image_digest" \ + --name "/apps/${{ env.app_name }}/${{ env.environment_name }}/image_digest" \ --type "String" \ --value "$digest" \ --overwrite @@ -86,7 +86,7 @@ jobs: workflow_id: 'deploy.yml', ref: 'main', inputs: { - app_name: 'sample-django-app', + app_name: '${{ env.app_name }}', environment: '${{ env.environment_name }}' } }) diff --git a/.github/workflows/build-staging.yml b/.github/workflows/build-staging.yml index 33d7496..0007eac 100644 --- a/.github/workflows/build-staging.yml +++ b/.github/workflows/build-staging.yml @@ -14,14 +14,13 @@ permissions: contents: read env: + app_name: sample-django-app environment_name: staging jobs: build_push: runs-on: ubuntu-latest environment: staging - outputs: - image_digest: ${{ steps.build_and_push.outputs.digest }} steps: - name: Checkout uses: actions/checkout@v4 @@ -33,6 +32,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Configure AWS Credentials + id: aws_auth uses: aws-actions/configure-aws-credentials@v4 with: audience: sts.amazonaws.com @@ -52,12 +52,14 @@ jobs: # Only building for AMD64 for now # platforms: linux/amd64,linux/arm64 push: true - tags: ${{ vars.ECR_REGISTRY }}/${{ vars.ECR_REPOSITORY }}:${{ github.sha }} + tags: | + ${{ vars.ECR_REGISTRY }}/${{ vars.ECR_REPOSITORY }}:${{ github.sha }} + ${{ vars.ECR_REGISTRY }}/${{ vars.ECR_REPOSITORY }}:latest - name: Push Image Digest to SSM run: | aws ssm put-parameter \ - --name "/apps/sample-django-app/${{ env.environment_name }}/image_digest" \ + --name "/apps/${{ env.app_name }}/${{ env.environment_name }}/image_digest" \ --type "String" \ --value "$digest" \ --overwrite @@ -90,7 +92,7 @@ jobs: workflow_id: 'deploy.yml', ref: 'main', inputs: { - app_name: 'sample-django-app', + app_name: '${{ env.app_name }}', environment: '${{ env.environment_name }}' } }) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e35d92f..0f2aa41 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,8 +10,8 @@ on: - '.github/environment/**' concurrency: - group: ${{ github.ref }} - cancel-in-progress: true + group: ${{ github.ref }} + cancel-in-progress: true permissions: id-token: write