Skip to content

Commit 81fc853

Browse files
committed
feat: Added GHCR URI tag extraction step
1 parent 07c17d6 commit 81fc853

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

.github/workflows/cd-base.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,25 @@ jobs:
2828
username: ${{ secrets.DOCKERHUB_USERNAME }}
2929
password: ${{ secrets.DOCKERHUB_TOKEN }}
3030

31+
- name: Extract tag name from GHCR
32+
id: extract
33+
run: |
34+
TAG=$(echo "${{ inputs.image_uri }}" | cut -d':' -f2)
35+
echo "tag=${TAG}" >> $GITHUB_OUTPUT
36+
37+
APP_NAME=$(echo "${{ inputs.image_uri }}" | cut -d'/' -f3 | cut -d':' -f1)
38+
echo "app_name=${APP_NAME}" >> $GITHUB_OUTPUT
39+
3140
- name: Pull -> re-tag -> push
3241
id: push
3342
run: |
34-
DOCKERHUB_IMAGE="${{ secrets.DOCKERHUB_USERNAME }}/mi-app:latest"
43+
DOCKERHUB_IMAGE="${{ secrets.DOCKERHUB_USERNAME }}/${{ steps.extract.outputs.app_name }}:${{ steps.extract.outputs.tag }}"
3544
docker pull ${{ inputs.image_uri }}
45+
3646
docker tag ${{ inputs.image_uri }} $DOCKERHUB_IMAGE
47+
3748
docker push $DOCKERHUB_IMAGE
49+
3850
echo "image_uri=$DOCKERHUB_IMAGE" >> $GITHUB_OUTPUT
3951
4052
deploy:

0 commit comments

Comments
 (0)