Skip to content

Commit

Permalink
Merge pull request #193 from DFE-Digital/add-production-build-and-pus…
Browse files Browse the repository at this point in the history
…h-workflow

Add Production build and push workflow
  • Loading branch information
DrizzlyOwl authored Jan 9, 2023
2 parents ae527d0 + 27ffaff commit c26b3f4
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-and-push-image-development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main

jobs:
build-and-push-image-development:
name: Build and push image development
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/build-and-push-image-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Continuous delivery

on:
push:
branches:
- main

jobs:
set-production-release-version:
name: Set Production Release Version
environment: production
runs-on: ubuntu-latest
outputs:
version: ${{ steps.release-version.outputs.version }}
steps:
- id: release-version
run: echo "version=release-4" >> $GITHUB_OUTPUT

build-and-push-image-production:
name: Build and push image production

runs-on: ubuntu-latest
needs: set-production-release-version

steps:
- name: Check out code
uses: actions/checkout@v3
with:
ref: ${{ needs.set-production-release-version.outputs.version }}

- name: Azure Container Registry login
uses: docker/login-action@v2
with:
username: ${{ secrets.PROD_AZURE_ACR_CLIENTID }}
password: ${{ secrets.PROD_AZURE_ACR_SECRET }}
registry: ${{ secrets.PROD_ACR_URL }}

- name: Prepare tags
id: prepare-tags
run: |
DOCKER_IMAGE=${{ secrets.PROD_ACR_URL }}/aca-app
VERSION=latest
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [ "${{ github.event_name }}" = "push" ]; then
VERSION=sha-${GITHUB_SHA}
TAGS="$TAGS,${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${{ needs.set-production-release-version.outputs.version }}"
fi
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "deploy-version=${VERSION}" >> $GITHUB_OUTPUT
- name: Push image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
build-args: ASPNET_IMAGE_TAG=6.0.9-bullseye-slim-amd64
push: true
tags: ${{ steps.prepare-tags.outputs.tags }}
6 changes: 3 additions & 3 deletions .github/workflows/build-and-push-image-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
environment: test
runs-on: ubuntu-latest
outputs:
version: ${{steps.release-version.outputs.version}}
version: ${{ steps.release-version.outputs.version }}
steps:
- id: release-version
run: echo "version=release-4" >> $GITHUB_OUTPUT
Expand All @@ -26,7 +26,7 @@ jobs:
- name: Check out code
uses: actions/checkout@v3
with:
ref: ${{needs.set-test-release-version.outputs.version}}
ref: ${{ needs.set-test-release-version.outputs.version }}

- name: Azure Container Registry login
uses: docker/login-action@v2
Expand All @@ -43,7 +43,7 @@ jobs:
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [ "${{ github.event_name }}" = "push" ]; then
VERSION=sha-${GITHUB_SHA}
TAGS="$TAGS,${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${{needs.set-test-release-version.outputs.version}}"
TAGS="$TAGS,${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${{ needs.set-test-release-version.outputs.version }}"
fi
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "deploy-version=${VERSION}" >> $GITHUB_OUTPUT
Expand Down

0 comments on commit c26b3f4

Please sign in to comment.