Skip to content

Commit 4865401

Browse files
committed
ci: add manual workflow to retag docker image by digest
1 parent eb0d3b6 commit 4865401

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Retag Docker Image
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
source_digest:
7+
description: "Source image digest (e.g. sha256:...)"
8+
required: true
9+
default: "sha256:8e3365b353614b2dfac36206e2b8a0ff97188c7b2958197fd5ed4451961b5d69"
10+
target_tags:
11+
description: "Comma-separated tags to update (e.g. altinity,latest)"
12+
required: true
13+
default: "altinity,latest"
14+
15+
env:
16+
REGISTRY: docker.io
17+
IMAGE_NAME: altinity/transferia
18+
19+
jobs:
20+
retag:
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
steps:
25+
- name: Validate inputs
26+
shell: bash
27+
run: |
28+
set -euo pipefail
29+
if [[ ! "${{ inputs.source_digest }}" =~ ^sha256:[a-f0-9]{64}$ ]]; then
30+
echo "Invalid digest format: ${{ inputs.source_digest }}"
31+
exit 1
32+
fi
33+
if [[ -z "${{ inputs.target_tags }}" ]]; then
34+
echo "target_tags cannot be empty"
35+
exit 1
36+
fi
37+
38+
- name: Set up Docker Buildx
39+
uses: docker/setup-buildx-action@v3
40+
41+
- name: Log in to Docker Hub
42+
uses: docker/login-action@v3
43+
with:
44+
registry: ${{ env.REGISTRY }}
45+
username: ${{ secrets.DOCKER_USERNAME }}
46+
password: ${{ secrets.DOCKER_PASSWORD }}
47+
48+
- name: Retag digest
49+
shell: bash
50+
run: |
51+
set -euo pipefail
52+
IFS=',' read -ra TAGS <<< "${{ inputs.target_tags }}"
53+
for tag in "${TAGS[@]}"; do
54+
clean_tag="$(echo "$tag" | xargs)"
55+
if [[ -z "$clean_tag" ]]; then
56+
continue
57+
fi
58+
echo "Retagging ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ inputs.source_digest }} -> ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${clean_tag}"
59+
docker buildx imagetools create \
60+
--tag "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${clean_tag}" \
61+
"${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ inputs.source_digest }}"
62+
done
63+

0 commit comments

Comments
 (0)