Skip to content

Commit

Permalink
feat: add immutable tag as a default
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonjord committed May 29, 2024
1 parent 3985c68 commit 955dfb3
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions .github/workflows/reusable-docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ on:
tags:
required: false
type: string
default: latest,git-${{ github.sha }}
description: |
a comma separated list of tags to image tags.
e.g:
- latest,20230607,git-deadb33f
- cooltag,v2.0.2
- latest
If no value provided, it will use the following tags
- latest
- the github sha
- a timestamp-sha -based tag (intended for workflows using immutable container tagging)
buildArgs:
required: false
type: string
Expand Down Expand Up @@ -136,12 +139,20 @@ on:
outputs:
image:
value: ${{ jobs.build.outputs.image }}
description: |
image uri based on digest
image-uri:
value: ${{ jobs.build.outputs.image-uri }}
description: |
image uri based on immutable container tag
jobs:
build:
runs-on: ${{ inputs.runs-on }}
timeout-minutes: ${{ inputs.timeout-mins }}
outputs:
image: ${{ steps.image.outputs.image }}
image-uri: ${{ steps.image-uri.outputs.image-uri }}
steps:
- if: ${{ startsWith(github.repository, 'GeoNet/') == false }}
name: require GeoNet org
Expand All @@ -155,6 +166,8 @@ jobs:
with:
version: ${{ env.VERSION_CRANE }}
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- id: tagging
uses: GeoNet/Actions/.github/actions/tagging@main
- name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
with:
Expand All @@ -171,7 +184,9 @@ jobs:
DOCKERFILE: ${{ inputs.dockerfile }}
REGISTRY_OVERRIDE: ${{ inputs.registryOverride }}
REGISTRY_GHCR_USERNAME_OVERRIDE: ${{ inputs.registryGhcrUsernameOverride }}
TAGS: ${{ inputs.tags }}
TAGS: ${{ inputs.tags == '' &&
format('{0},{1},{2}', 'latest', github.sha, steps.tagging.outputs.tag) ||
inputs.tags }}
BUILD_ARGS: ${{ inputs.buildArgs }}
PLATFORMS: ${{ inputs.platforms }}
PUSH: ${{ inputs.push }}
Expand Down Expand Up @@ -230,7 +245,9 @@ jobs:
REGISTRY_OVERRIDE: ${{ inputs.registryOverride }}
GHCR_DOCKER_REPO: ghcr.io/${{ github.repository }}
IMAGE_NAME: ${{ inputs.imageName }}
TAGS: ${{ inputs.tags }}
TAGS: ${{ inputs.tags == '' &&
format('{0},{1},{2}', 'latest', github.sha, steps.tagging.outputs.tag) ||
inputs.tags }}
PLATFORMS: ${{ inputs.platforms }}
PUSH: ${{ inputs.push }}
run: |
Expand Down Expand Up @@ -357,6 +374,11 @@ jobs:
id: image
run: |
echo "image=${{ steps.run-info.outputs.image }}@${{ steps.get-digests.outputs.destination }}" >> $GITHUB_OUTPUT
- name: image-uri
if: ${{ input.tags == '' }}
id: image-uri
run: |
echo "image-uri={{ steps.run-info.outputs.image }}:${{ steps.tagging.outputs.tag }}" >> $GITHUB_OUTPUT
- name: image result
if: ${{ inputs.push == true }}
id: result
Expand Down

0 comments on commit 955dfb3

Please sign in to comment.