This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Activate docker distribution | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: "The name of the environment for the node" | |
type: choice | |
options: | |
- stagenet | |
- testnet | |
- mainnet | |
default: "stagenet" | |
source_image_tag: | |
description: "The tag that should be renamed" | |
required: true | |
type: string | |
destination_image_tag: | |
description: "The new tag name" | |
required: true | |
type: string | |
set_latest: | |
description: "Should latest tag be assigned to this image" | |
type: boolean | |
default: true | |
delete_source: | |
description: "Should the old tag be deleted" | |
type: boolean | |
default: false | |
push: | |
branches: | |
- ekw/SRE-1052/various-fixes | |
env: | |
SOURCE_IMAGE_TAG: "concordium/stagenet-node:4.3.1-rc1test1" #"concordium/${{ inputs.environment }}-node:${{ inputs.source_image_tag }}" | |
DESTINATION_IMAGE_TAG: "concordium/stagenet-node:4.3.1-rc1test2" #"concordium/${{ inputs.environment }}-node:${{ inputs.destination_image_tag }}" | |
jobs: | |
update-docker-tag: | |
runs-on: ubuntu-latest | |
environment: rename-tags | |
steps: | |
- name: "dockerhub-login" | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: "Check Source image tag" | |
run: | | |
set +e | |
docker manifest inspect ${{ env.SOURCE_IMAGE_TAG }} | |
EXIT_CODE=$? | |
if [[ $EXIT_CODE -eq 1 ]]; then | |
echo "ERROR: image ${{ env.SOURCE_IMAGE_TAG }} does not exist" | |
exit 1 | |
elif [[ $EXIT_CODE -ne 0 ]]; then | |
echo "ERROR: $EXIT_CODE" | |
exit 1 | |
fi | |
- name: "Check destination image tag" | |
run: | | |
set +e | |
docker manifest inspect ${{ env.DESTINATION_IMAGE_TAG }} | |
EXIT_CODE=$? | |
if [[ $EXIT_CODE -eq 0 ]]; then | |
echo "ERROR: image ${{ env.DESTINATION_IMAGE_TAG }} already exist" | |
exit 1 | |
elif [[ $EXIT_CODE -ne 1 ]]; then | |
echo "ERROR: $EXIT_CODE" | |
exit 1 | |
fi | |
- name: "Update image tag" | |
run: | | |
set +e | |
docker pull ${{ env.SOURCE_IMAGE_TAG }} | |
docker image tag ${{ env.SOURCE_IMAGE_TAG }} ${{ env.DESTINATION_IMAGE_TAG }} | |
if [[ false ]]; then | |
docker image tag ${{ env.SOURCE_IMAGE_TAG }} latest | |
fi | |
docker push ${{ env.DESTINATION_IMAGE_TAG }} | |
if [[ true ]]; then | |
#docker rmi docker.io/${{ env.SOURCE_IMAGE_TAG }} | |
TOKEN=`curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"${{ secrets.DOCKERHUB_USERNAME}}\", \"password\": \"${{ secrets.DOCKERHUB_TOKEN }}\"}" "https://hub.docker.com/v2/users/login/" | jq -r .token` | |
curl "https://hub.docker.com/v2/repositories/concordium/stagenet-node/tags/4.3.1-rc1test3/" -X DELETE -H "Authorization: JWT $TOKEN" | |
fi |