Skip to content

Commit

Permalink
Merge pull request #520 from MrAnno/custom-snapshot-tags
Browse files Browse the repository at this point in the history
ci: allow non-overridable custom tags for snapshot images
  • Loading branch information
OverOrion authored Feb 24, 2025
2 parents 0c505bb + 921a946 commit 866d684
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/axosyslog-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ jobs:
merge-and-push:
runs-on: ubuntu-latest
needs: [prepare, image-build]
outputs:
tags: ${{ steps.docker-metadata-tags.outputs.tags }}
steps:
- name: Download digests
uses: actions/download-artifact@v4
Expand All @@ -139,6 +137,7 @@ jobs:
uses: docker/setup-buildx-action@v3

- name: "Query previous container image version"
if: inputs.type == 'stable'
uses: actions/github-script@v7
with:
script: |
Expand All @@ -160,8 +159,11 @@ jobs:
previousDockerTag = tags.find(t => versionPattern.test(t));
core.exportVariable('previous_docker_tag', previousDockerTag);
- name: Extract metadata (AxoSyslog version) for Docker
- name: Generate next AxoSyslog container image tag
id: docker-metadata-tags
if: inputs.type == 'stable'
env:
IMAGE_NAME: ${{ needs.prepare.outputs.image-name }}
run: |
previous_docker_tag_short=$(echo $previous_docker_tag | cut -d"-" -f1)
previous_docker_tag_rebuild_num=$(echo $previous_docker_tag | cut -d"-" -f2)
Expand All @@ -182,7 +184,7 @@ jobs:
echo "Rebuilding an older AxoSyslog version is not allowed. Please provide a valid git tag version."
exit 1
fi
TAGS="ghcr.io/axoflow/axosyslog:$next_docker_tag,ghcr.io/axoflow/axosyslog:$next_docker_tag_with_patch,ghcr.io/axoflow/axosyslog:latest"
TAGS="$IMAGE_NAME:$next_docker_tag,$IMAGE_NAME:$next_docker_tag_with_patch,$IMAGE_NAME:latest"
echo "tags=$TAGS" >> $GITHUB_OUTPUT
fi
Expand Down
44 changes: 42 additions & 2 deletions .github/workflows/axosyslog-image-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,52 @@ on:
inputs:
platforms:
default: "linux/amd64,linux/arm64"
type:
description: 'Snapshot type'
required: true
default: 'branch'
type: choice
options:
- branch
- custom
custom-tag:
description: 'Custom tag name (only used if custom type is selected)'
required: false
type: string
default: 'x.y.z-axoflow.something'
push:
branches:
- main

jobs:
prepare:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
env:
IMAGE_NAME: "ghcr.io/${{ github.repository_owner }}/axosyslog"
steps:
- name: Determine tag
id: tag
run: |
IMAGE_NAME="$(echo "$IMAGE_NAME" | tr '[:upper:]' '[:lower:]')"
case "${{ inputs.type || 'branch' }}" in
branch)
tag="dev-${{ github.ref_name }}"
;;
custom)
if docker manifest inspect "$IMAGE_NAME:${{ inputs.custom-tag }}" > /dev/null 2>&1; then
echo "Custom tag '${{ inputs.custom-tag }}' already exists."
exit 1
fi
tag="${{ inputs.custom-tag }}"
;;
esac
echo "tag=${tag}" >> $GITHUB_OUTPUT
echo "tag=${tag}"
tarball:
needs: prepare
runs-on: ubuntu-latest
outputs:
snapshot-version: ${{ steps.snapshot-version.outputs.SNAPSHOT_VERSION }}
Expand Down Expand Up @@ -44,10 +84,10 @@ jobs:
publish-image:
permissions: write-all
uses: ./.github/workflows/axosyslog-docker.yml
needs: tarball
needs: [prepare, tarball]
with:
type: snapshot
platforms: ${{ inputs.platforms || 'linux/amd64,linux/arm64' }}
snapshot-tarball-artifact: source-tarball
snapshot-version: ${{ needs.tarball.outputs.snapshot-version }}
snapshot-tags: dev-${{ github.ref_name }}
snapshot-tags: ${{ needs.prepare.outputs.tag }}

0 comments on commit 866d684

Please sign in to comment.