trying to re-tag image
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -16,7 +16,7 @@ jobs:
|
|||||||
- name: Build docker image
|
- name: Build docker image
|
||||||
run: |
|
run: |
|
||||||
docker build -t umbrella .
|
docker build -t umbrella .
|
||||||
docker tag umbrella ${{ secrets.REGISTRY_PATH }}/umbrella:latest
|
docker tag umbrella ${{ secrets.REGISTRY_PATH }}/umbrella:${{ gitea.ref_name }}
|
||||||
|
|
||||||
- name: Login to registry
|
- name: Login to registry
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
@@ -25,7 +25,28 @@ jobs:
|
|||||||
username: ${{ secrets.REGISTRY_USER }}
|
username: ${{ secrets.REGISTRY_USER }}
|
||||||
password: ${{ secrets.REGISTRY_PASS }}
|
password: ${{ secrets.REGISTRY_PASS }}
|
||||||
|
|
||||||
|
- name: Re-tag the most recent image
|
||||||
|
- run: |
|
||||||
|
REGISTRY="${{ secrets.REGISTRY_PATH }}"
|
||||||
|
REPO="umbrella"
|
||||||
|
USER="${{ secrets.DOCKER_USERNAME }}"
|
||||||
|
PASS="${{ secrets.DOCKER_PASSWORD }}"
|
||||||
|
LATEST="${{ gitea.ref_name }}"
|
||||||
|
NEW_TAG="${{ gitea.sha_short }}"
|
||||||
|
|
||||||
|
# Get auth token (basic auth for most self-hosted registries)
|
||||||
|
TOKEN=$(curl -s -u "$USER:$PASS" "https://$REGISTRY/v2/token?service=$REGISTRY&scope=repository:$REPO:pull,push")
|
||||||
|
AUTH="Bearer $(echo $TOKEN | jq -r .token)"
|
||||||
|
|
||||||
|
# Fetch latest manifest (specify mediaType header for OCI support)
|
||||||
|
MANIFEST=$(curl -s -H "Authorization: $AUTH" -H "Accept: application/vnd.docker.distribution.manifest.v2+json,application/vnd.oci.image.manifest.v1+json" "https://$REGISTRY/v2/$REPO/manifests/$LATEST" | jq -c .)
|
||||||
|
|
||||||
|
# PUT manifest under new tag
|
||||||
|
curl -X PUT -s -H "Authorization: $AUTH" -H "Content-Type: application/vnd.docker.distribution.manifest.v2+json" --data "$MANIFEST" "https://$REGISTRY/v2/$REPO/manifests/$NEW_TAG"
|
||||||
|
|
||||||
|
echo "Tagged $REGISTRY/$REPO:$LATEST -> $NEW_TAG"
|
||||||
|
|
||||||
- name: Push to registry
|
- name: Push to registry
|
||||||
# if: startsWith(gitea.ref, 'refs/tags/')
|
# if: startsWith(gitea.ref, 'refs/tags/')
|
||||||
run: |
|
run: |
|
||||||
docker push ${{ secrets.REGISTRY_PATH }}/umbrella:latest
|
docker push ${{ secrets.REGISTRY_PATH }}/umbrella:${{ gitea.ref_name }}
|
||||||
|
|||||||
Reference in New Issue
Block a user