Skip to content

Commit

Permalink
Merge pull request #94 from clearlydefined/elr/version-in-docker
Browse files Browse the repository at this point in the history
add version and sha in docker image instead of Azure configs
  • Loading branch information
ljones140 authored Oct 3, 2024
2 parents 89e3f89 + b5da786 commit b3fa1f7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 30 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/app-build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This workflow will build a docker image, push it to ghcr.io, and deploy it to an Azure WebApp.
# v2.0.0 - This tag coordinates the other reusable parts of this workflow.
# v3.0.0 - This tag coordinates the other reusable parts of this workflow.
# * app-build-docker-image.yml
# * app-deploy-to-azure.yml
# * app-is-deployable.yml
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
uses: actions/[email protected]
with:
repository: 'clearlydefined/operations'
ref: 'v2.0.0'
ref: 'v3.0.0'
path: 'operations'
- name: Get version from package-lock.json
id: get_version
Expand All @@ -97,20 +97,20 @@ jobs:
build-and-publish-image:
name: Build and publish Docker image
needs: get-version
uses: clearlydefined/operations/.github/workflows/app-build-docker-image.yml@v2.0.0
uses: ./.github/workflows/app-build-docker-image.yml
secrets:
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
PRODUCTION_DEPLOYERS: ${{ secrets.PRODUCTION_DEPLOYERS }}
with:
deploy-env: ${{ inputs.deploy-env }}
application-type: ${{ inputs.application-type }}
image-tag: ${{ needs.get-version.outputs.version }}
application-version: ${{ needs.get-version.outputs.version }}
build-args: ${{ inputs.docker-build-args }}

deploy-primary-app-to-azure:
name: Deploy to primary Azure app
needs: [get-version, build-and-publish-image]
uses: clearlydefined/operations/.github/workflows/app-deploy-to-azure.yml@v2.0.0
uses: ./.github/workflows/app-deploy-to-azure.yml
secrets:
AZURE_WEBAPP_PUBLISH_PROFILE: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
Expand All @@ -119,14 +119,13 @@ jobs:
with:
deploy-env: ${{ inputs.deploy-env }}
azure-webapp-name: ${{ inputs.azure-app-base-name }}${{ inputs.azure-app-name-postfix }}
application-version: ${{ needs.get-version.outputs.version }}
image-name-with-tag: ${{ needs.build-and-publish-image.outputs.docker-image-name-with-tag }}

deploy-secondary-app-to-azure:
name: Deploy to secondary Azure app
if: ${{ inputs.secondary-azure-app-name-postfix != '' }}
needs: [get-version, build-and-publish-image]
uses: clearlydefined/operations/.github/workflows/app-deploy-to-azure.yml@v2.0.0
uses: ./.github/workflows/app-deploy-to-azure.yml
secrets:
AZURE_WEBAPP_PUBLISH_PROFILE: ${{ secrets.AZURE_SECONDARY_WEBAPP_PUBLISH_PROFILE }}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
Expand All @@ -135,5 +134,4 @@ jobs:
with:
deploy-env: ${{ inputs.deploy-env }}
azure-webapp-name: ${{ inputs.azure-app-base-name }}${{ inputs.secondary-azure-app-name-postfix }}
application-version: ${{ needs.get-version.outputs.version }}
image-name-with-tag: ${{ needs.build-and-publish-image.outputs.docker-image-name-with-tag }}
13 changes: 8 additions & 5 deletions .github/workflows/app-build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
description: 'application type (i.e. api | worker | ui) - used as a label for the Docker image'
required: true
type: string
image-tag:
application-version:
description: 'the tag to use for the image (e.g. prod: v1.2.0, dev: v1.2.0+dev:1D3F567890)'
required: true
type: string
Expand All @@ -35,7 +35,7 @@ on:

jobs:
check-deployable:
uses: clearlydefined/operations/.github/workflows/app-is-deployable.yml@v2.0.0
uses: ./.github/workflows/app-is-deployable.yml
with:
deploy-env: ${{ inputs.deploy-env }}
secrets:
Expand All @@ -52,7 +52,7 @@ jobs:
uses: actions/[email protected]
with:
repository: 'clearlydefined/operations'
ref: 'v2.0.0'
ref: 'v3.0.0'
path: 'operations'
- name: Determine Docker Image Name
id: determine_image_name
Expand All @@ -61,7 +61,7 @@ jobs:
script_log=$(./operations/scripts/app-workflows/determine-image-name.sh \
"${{ github.repository }}" \
"${{ inputs.deploy-env }}" \
"${{ inputs.image-tag }}") || (echo "$script_log" && exit 1)
"${{ inputs.application-version }}") || (echo "$script_log" && exit 1)
echo -e "---- script log\n$script_log\n----"; \
image_name=$(echo "$script_log" | tail -n 1)
echo "DOCKER_IMAGE_NAME_WITH_TAG=$image_name" >> $GITHUB_ENV
Expand All @@ -87,7 +87,10 @@ jobs:
context: .
push: true
file: Dockerfile
build-args: ${{ inputs.build-args }}
build-args: |
APP_VERSION=${{ inputs.application-version }}
BUILD_SHA=${{ github.sha }}
${{ inputs.build-args }}
tags: ${{ needs.determine-image-name.outputs.docker-image-name-with-tag }}
labels: |
env=${{ inputs.deploy-env }}
Expand Down
16 changes: 1 addition & 15 deletions .github/workflows/app-deploy-to-azure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,14 @@ on:
description: 'Azure application name of application to deploy (i.e. clearlydefined-api | cdcrawler | clearlydefined)'
required: true
type: string
application-version:
description: 'the tag to use for the image (e.g. prod: v1.2.0, dev: v1.2.0+dev:1D3F567890)'
required: true
type: string
image-name-with-tag:
description: 'Docker image name with the tag (e.g. ghcr.io/clearlydefined/clearlydefined-api:v1.2.0)'
required: true
type: string

jobs:
check-deployable:
uses: clearlydefined/operations/.github/workflows/app-is-deployable.yml@v2.0.0
uses: ./.github/workflows/app-is-deployable.yml
with:
deploy-env: ${{ inputs.deploy-env }}
secrets:
Expand Down Expand Up @@ -69,16 +65,6 @@ jobs:
"name": "DOCKER_REGISTRY_SERVER_URL",
"value": "https://ghcr.io",
"slotSetting": false
},
{
"name": "APP_VERSION",
"value": "${{ inputs.application-version }}",
"slotSetting": false
},
{
"name": "BUILD_SHA",
"value": "${{ github.sha }}",
"slotSetting": false
}
]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/app-is-deployable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/[email protected]
with:
repository: 'clearlydefined/operations'
ref: 'v2.0.0'
ref: 'v3.0.0'
path: 'operations'
- id: confirm-dev
shell: bash
Expand All @@ -47,7 +47,7 @@ jobs:
uses: actions/[email protected]
with:
repository: 'clearlydefined/operations'
ref: 'v2.0.0'
ref: 'v3.0.0'
path: 'operations'

- name: Get organization ID
Expand Down

0 comments on commit b3fa1f7

Please sign in to comment.