Merge pull request #517 from bshifter/fx-cache-file-json #389
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: AxoSyslog snapshot image | |
on: | |
workflow_dispatch: | |
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 }} | |
steps: | |
- name: Checkout AxoSyslog source | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Prepare docker image | |
run: ./dbld/rules cache-image-tarball | |
- name: Create source tarball | |
run: ./dbld/rules pkg-tarball | |
- name: Determine snapshot version | |
id: snapshot-version | |
run: | | |
tarball_filename="$(find dbld/build -name '*.tar.*' -printf '%f\n')" | |
tarball_name="${tarball_filename/\.tar.*}" | |
tarball_version="${tarball_name/axosyslog-}" | |
pkg_version="$(echo $tarball_version | sed -E 's|(([0-9]+\.){2}[0-9]+).*|\1|')_git$(date +%Y%m%d)" | |
echo "SNAPSHOT_VERSION=${pkg_version}" >> $GITHUB_OUTPUT | |
- name: Store source tarball as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: source-tarball | |
path: dbld/build/*.tar.* | |
publish-image: | |
permissions: write-all | |
uses: ./.github/workflows/axosyslog-docker.yml | |
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: ${{ needs.prepare.outputs.tag }} |