From 833170885dcaf4c97fd84e3f986c4edefbdf5e50 Mon Sep 17 00:00:00 2001 From: tcely Date: Sat, 31 May 2025 22:38:00 -0400 Subject: [PATCH 1/4] Generate `missing-tags` list --- .github/workflows/ci.yaml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5ae58c0a..570568ff 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -30,7 +30,33 @@ jobs: lowercase-github-repository_owner: ${{ steps.github-repository_owner.outputs.lowercase }} ytdlp-latest-release: ${{ steps.yt-dlp.outputs.latest-release }} ytdlp-releases: ${{ steps.yt-dlp.outputs.releases }} + missing-tags: ${{ steps.tagged.outputs.missing }} steps: + - name: Pull tagged releases + id: tagged + run: | + set_sl_var() { local f='%s=%s\n' ; printf -- "${f}" "$@" ; } ; + missing='' + image='ghcr.io/meeb/tubesync' + # v0.14.1 = ghcr.io/meeb/tubesync:latest@sha256:63fffee3411bda395c526087d7107f76834141bb0c1443a0bd6bed5533e5a85f + tag_tried='v0.14.1' + tag_image_digest='latest@sha256:63fffee3411bda395c526087d7107f76834141bb0c1443a0bd6bed5533e5a85f' + docker pull "${image}:${tag_image_digest}" + docker pull "${image}:${tag_tried}" && tag_found=1 || { + tag_found=0 + missing="${missing}${missing:+|}${tag_tried}=${image}:${tag_image_digest}" + } + set_sl_var "${tag_tried}" "${tag_found}" >> "${GITHUB_OUTPUT}" + # v0.15.1 = ghcr.io/meeb/tubesync:latest@sha256:7303b2d8854aac15f94dbbfdd0ee66ca598ade1af6ac2d9e3d886c93ffa2d596 + tag_tried='v0.15.1' + tag_image_digest='latest@sha256:7303b2d8854aac15f94dbbfdd0ee66ca598ade1af6ac2d9e3d886c93ffa2d596' + docker pull "${image}:${tag_image_digest}" + docker pull "${image}:${tag_tried}" && tag_found=1 || { + tag_found=0 + missing="${missing}${missing:+|}${tag_tried}=${image}:${tag_image_digest}" + } + set_sl_var "${tag_tried}" "${tag_found}" >> "${GITHUB_OUTPUT}" + set_sl_var missing "${missing}" >> "${GITHUB_OUTPUT}" - uses: actions/checkout@v4 - name: Lowercase github username id: github-actor From 97f3365675eb936cbeaae01b9cb9134053c1fb87 Mon Sep 17 00:00:00 2001 From: tcely Date: Sat, 31 May 2025 23:23:18 -0400 Subject: [PATCH 2/4] Push the tags created from the `missing-tags` output --- .github/workflows/ci.yaml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 570568ff..323bed17 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -35,9 +35,10 @@ jobs: - name: Pull tagged releases id: tagged run: | - set_sl_var() { local f='%s=%s\n' ; printf -- "${f}" "$@" ; } ; + image='ghcr.io/meeb/${{ env.IMAGE_NAME }}' missing='' - image='ghcr.io/meeb/tubesync' + set_sl_var() { local f='%s=%s\n' ; printf -- "${f}" "$@" ; } ; + set -eux # v0.14.1 = ghcr.io/meeb/tubesync:latest@sha256:63fffee3411bda395c526087d7107f76834141bb0c1443a0bd6bed5533e5a85f tag_tried='v0.14.1' tag_image_digest='latest@sha256:63fffee3411bda395c526087d7107f76834141bb0c1443a0bd6bed5533e5a85f' @@ -194,6 +195,21 @@ jobs: DOCKER_USERNAME: ${{ github.actor }} DOCKER_TOKEN: ${{ 'meeb' == github.repository_owner && secrets.REGISTRY_ACCESS_TOKEN || secrets.GITHUB_TOKEN }} run: echo "${DOCKER_TOKEN}" | docker login --password-stdin --username "${DOCKER_USERNAME}" "${DOCKER_REGISTRY}" + - name: Push missing release tags + if: ${{ github.actor == github.repository_owner && '' != needs.info.outputs.missing-tags }} + run: | + missing='${{ needs.info.outputs.missing-tags }}' + image='ghcr.io/${{ needs.info.outputs.lowercase-github-actor }}/${{ env.IMAGE_NAME }}' + printf -- '%s\n' "${missing}" | tr '|' '\n' | \ + while read SPEC + do + printf -- '%s\n' "${SPEC}" | ( IFS='=' ; \ + read tag source && \ + docker pull "${source}" && \ + docker tag "${source}" "${image}:${tag}" && \ + docker push "${image}:${tag}" ; + ) + done - name: Build image for `dive` id: build-dive-image uses: docker/build-push-action@v6 From 819a0f7e842a7bc90b60b646770286e8414a8d8f Mon Sep 17 00:00:00 2001 From: tcely Date: Sat, 31 May 2025 23:29:51 -0400 Subject: [PATCH 3/4] Use a `missing-tags-image` output --- .github/workflows/ci.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 323bed17..db62d124 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -31,6 +31,7 @@ jobs: ytdlp-latest-release: ${{ steps.yt-dlp.outputs.latest-release }} ytdlp-releases: ${{ steps.yt-dlp.outputs.releases }} missing-tags: ${{ steps.tagged.outputs.missing }} + missing-tags-image: ${{ steps.tagged.outputs.image }} steps: - name: Pull tagged releases id: tagged @@ -39,6 +40,7 @@ jobs: missing='' set_sl_var() { local f='%s=%s\n' ; printf -- "${f}" "$@" ; } ; set -eux + set_sl_var image "${image}" >> "${GITHUB_OUTPUT}" # v0.14.1 = ghcr.io/meeb/tubesync:latest@sha256:63fffee3411bda395c526087d7107f76834141bb0c1443a0bd6bed5533e5a85f tag_tried='v0.14.1' tag_image_digest='latest@sha256:63fffee3411bda395c526087d7107f76834141bb0c1443a0bd6bed5533e5a85f' @@ -199,7 +201,7 @@ jobs: if: ${{ github.actor == github.repository_owner && '' != needs.info.outputs.missing-tags }} run: | missing='${{ needs.info.outputs.missing-tags }}' - image='ghcr.io/${{ needs.info.outputs.lowercase-github-actor }}/${{ env.IMAGE_NAME }}' + image='${{ needs.info.outputs.missing-tags-image }}' printf -- '%s\n' "${missing}" | tr '|' '\n' | \ while read SPEC do From 581512251ac28814822b80f3c169589ba49b6841 Mon Sep 17 00:00:00 2001 From: tcely Date: Sat, 31 May 2025 23:45:49 -0400 Subject: [PATCH 4/4] Restrict pushing tags to only meeb --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index db62d124..117ec78e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -198,7 +198,7 @@ jobs: DOCKER_TOKEN: ${{ 'meeb' == github.repository_owner && secrets.REGISTRY_ACCESS_TOKEN || secrets.GITHUB_TOKEN }} run: echo "${DOCKER_TOKEN}" | docker login --password-stdin --username "${DOCKER_USERNAME}" "${DOCKER_REGISTRY}" - name: Push missing release tags - if: ${{ github.actor == github.repository_owner && '' != needs.info.outputs.missing-tags }} + if: ${{ 'meeb' == github.actor && github.actor == github.repository_owner && '' != needs.info.outputs.missing-tags }} run: | missing='${{ needs.info.outputs.missing-tags }}' image='${{ needs.info.outputs.missing-tags-image }}'