33 push :
44 branches :
55 - main
6+ tags :
7+ - ' v*'
68 paths-ignore :
79 - ' docs/**'
810 - ' config/**'
911 workflow_dispatch :
12+ inputs :
13+ tag :
14+ description : ' preview image tag; when set, builds as a tag release preview'
15+ required : false
16+ type : string
1017
1118permissions :
1219 contents : read
2431 steps :
2532 - name : Checkout
2633 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
34+ with :
35+ ref : ${{ github.event.inputs.tag || github.ref }}
2736 - name : Setup Go
2837 uses : actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
2938 with :
@@ -38,13 +47,33 @@ jobs:
3847 run : make web-ci-install web-build
3948 - name : Prepare
4049 id : prep
50+ env :
51+ MANUAL_TAG : ${{ github.event.inputs.tag }}
4152 run : |
4253 TIMESTAMP=$(git log -1 --pretty=%ct)
43- TAG="${GITHUB_REF_NAME//\//-}-${GITHUB_SHA::8}-${TIMESTAMP}"
44- LATEST_TAG="${GITHUB_REF_NAME//\//-}-latest"
4554 echo "TIMESTAMP=${TIMESTAMP}" >> $GITHUB_OUTPUT
46- echo "TAG=${TAG}" >> $GITHUB_OUTPUT
47- echo "LATEST_TAG=${LATEST_TAG}" >> $GITHUB_OUTPUT
55+
56+ if [[ -n "${MANUAL_TAG}" ]]; then
57+ VERSION="${MANUAL_TAG}-1"
58+ TAG="${MANUAL_TAG}"
59+ BRANCH_BUILD=false
60+ elif [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
61+ VERSION="${GITHUB_REF_NAME}-1"
62+ TAG="${GITHUB_REF_NAME}"
63+ BRANCH_BUILD=false
64+ else
65+ TAG="${GITHUB_REF_NAME//\//-}-${GITHUB_SHA::8}-${TIMESTAMP}"
66+ LATEST_TAG="${GITHUB_REF_NAME//\//-}-latest"
67+ VERSION="0.0.0-${TAG}"
68+ BRANCH_BUILD=true
69+ fi
70+
71+ {
72+ echo "VERSION=${VERSION}"
73+ echo "TAG=${TAG}"
74+ echo "LATEST_TAG=${LATEST_TAG}"
75+ echo "BRANCH_BUILD=${BRANCH_BUILD}"
76+ } >> $GITHUB_OUTPUT
4877 - name : Setup QEMU
4978 uses : docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
5079 - name : Setup Docker Buildx
6493 ${{ env.IMAGE }}
6594 tags : |
6695 type=raw,value=${{ steps.prep.outputs.TAG }}
67- type=raw,value=${{ steps.prep.outputs.LATEST_TAG }}
96+ type=raw,value=${{ steps.prep.outputs.LATEST_TAG }},enable=${{ steps.prep.outputs.BRANCH_BUILD == 'true' }}
6897 annotations :
6998 org.opencontainers.image.description=Flux Operator preview build
7099 - name : Push image
@@ -83,10 +112,11 @@ jobs:
83112 tags : ${{ steps.meta.outputs.tags }}
84113 labels : ${{ steps.meta.outputs.labels }}
85114 annotations : ${{ steps.meta.outputs.annotations }}
86- build-args : " VERSION=0.0.0- ${{ steps.prep.outputs.TAG }}"
115+ build-args : " VERSION=${{ steps.prep.outputs.VERSION }}"
87116 - uses : sigstore/cosign-installer@ba7bc0a3fef59531c69a25acd34668d6d3fe6f22 # v4.1.0
88117 - name : Sign image
89118 env :
90119 COSIGN_EXPERIMENTAL : 1
120+ IMAGE_DIGEST : ${{ steps.build-push.outputs.digest }}
91121 run : |
92- cosign sign --yes ${{ env. IMAGE }} @${{ steps.build-push.outputs.digest }}
122+ cosign sign --yes "${ IMAGE} @${IMAGE_DIGEST}"
0 commit comments