Skip to content

Commit

Permalink
Specify Docker image version tag in a config file
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Moore <[email protected]>
  • Loading branch information
drmrd committed Nov 29, 2023
1 parent 39694d5 commit ce529fd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions .docker_image_version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.3
35 changes: 21 additions & 14 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
name: cicd

on:
push:
branches:
- 'build_pkg_**'
tags:
- 'v*'
pull_request:
branches:
- 'main'

jobs:
docker-build-and-push-images:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

strategy:
matrix:
include:
Expand All @@ -31,6 +21,25 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Ensure Docker image version is not referencing an existing release
id: docker-image-version-check
run: |
if ! [[ -s .docker_image_version ]]; then
echo 'Error: No .docker_image_version file found.'
exit 1
fi
SEMVER="$(cat .docker_images_version)"
if git show-ref --tags --verify --quiet "refs/tags/v${SEMVER}"; then
echo "Error: The tag 'v${SEMVER}' is already a GitHub release.'
echo ' Please update the version in .docker_image_version'
exit 1
else
echo "SEMVER=${SEMVER}" >> "${GITHUB_OUTPUT}"
fi
- name: Set Docker image metadata
id: meta
Expand All @@ -40,11 +49,9 @@ jobs:
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern=${{ steps.docker-image-version-check.SEMVER }}
- name: Log into GitHub container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
Expand All @@ -55,6 +62,6 @@ jobs:
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
push: ${{ github.event_name != 'pull_request' }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit ce529fd

Please sign in to comment.