-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (82 loc) · 3.02 KB
/
activate-docker-distribution.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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=1
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-rc1test1/" -X DELETE -H "Authorization: JWT \${TOKEN}"
fi