-
-
Notifications
You must be signed in to change notification settings - Fork 63
155 lines (135 loc) · 7.69 KB
/
push_new_version.yml
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Push New Version
on:
workflow_dispatch:
inputs:
tag:
description: "The semantic version to assign to the new Tag"
required: true
type: string
dryrun:
description: "Run the action without pushing anything"
required: true
type: boolean
default: true
builder:
description: "The builder to use for the new Tag"
required: true
type: choice
options:
- buildah
- docker
default: "buildah"
defaults:
run:
shell: bash
jobs:
tag_repo:
name: "Add a Tag to the Repo"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: GitHub Tag
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ github.event.inputs.tag }}
create_annotated_tag: true
dry_run: ${{ github.event.inputs.dryrun }}
build_and_push_image:
name: "Build the new Image"
runs-on: ubuntu-latest
needs:
- tag_repo
steps:
- uses: actions/checkout@v3
- name: Set Variables
id: variables
run: |
echo "::set-output name=dkimagepath::renegademaster/zomboid-dedicated-server"
echo "::set-output name=ghimagepath::renegade-master/zomboid-dedicated-server"
echo "::set-output name=qyimagepath::renegade_master/zomboid-dedicated-server"
echo "::set-output name=datetime::$(date +%Y%m%dT%H%M%SZ)"
- name: Login to Image Repositories
run: |
docker login -u ${{ secrets.GH_USER }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_TOKEN }} docker.io
docker login -u ${{ secrets.QUAY_USER }} -p ${{ secrets.QUAY_TOKEN }} quay.io
- name: Start Local Container Registry
run: podman run --rm --detach --publish 5000:5000 --name registry docker.io/registry
- name: Build the Image
run: |
if [[ ${{ github.event.inputs.builder }} == "buildah" ]]; then
BUILDAH_LAYERS=true buildah bud \
--file docker/zomboid-dedicated-server.Dockerfile \
--tag localhost:5000/${{ steps.variables.outputs.ghimagepath }}:${{ github.event.inputs.tag }} \
.
elif [[ ${{ github.event.inputs.builder }} == "docker" ]]; then
docker build \
--file docker/zomboid-dedicated-server.Dockerfile \
--tag localhost:5000/${{ steps.variables.outputs.ghimagepath }}:${{ github.event.inputs.tag }} \
.
fi
- name: Push the Image to Local Container Registry
run: |
if [[ ${{ github.event.inputs.builder }} == "buildah" ]]; then
buildah push localhost:5000/${{ steps.variables.outputs.ghimagepath }}:${{ github.event.inputs.tag }}
elif [[ ${{ github.event.inputs.builder }} == "docker" ]]; then
docker push localhost:5000/${{ steps.variables.outputs.ghimagepath }}:${{ github.event.inputs.tag }}
fi
- name: Inspect the Image
run: skopeo inspect --tls-verify=false docker://localhost:5000/${{ steps.variables.outputs.ghimagepath }}:${{ github.event.inputs.tag }}
- name: Push new Image Tags
run: |
if [[ "${{ github.event.inputs.dryrun }}" == "false" ]]; then
printf "Pushing Image Tags\n"
printf "\nPushing GitHub Image...\n"
skopeo copy --src-tls-verify=false --dest-creds ${{ secrets.GH_USER }}:${{ secrets.GITHUB_TOKEN }} \
docker://localhost:5000/${{ steps.variables.outputs.ghimagepath }}:${{ github.event.inputs.tag }} \
docker://ghcr.io/${{ steps.variables.outputs.ghimagepath }}:${{ github.event.inputs.tag }}
skopeo copy --src-tls-verify=false --dest-creds ${{ secrets.GH_USER }}:${{ secrets.GITHUB_TOKEN }} \
docker://localhost:5000/${{ steps.variables.outputs.ghimagepath }}:${{ github.event.inputs.tag }} \
docker://ghcr.io/${{ steps.variables.outputs.ghimagepath }}:latest
printf "\nPushing DockerHub Image...\n"
skopeo copy --src-tls-verify=false --dest-creds ${{ secrets.DOCKER_USER }}:${{ secrets.DOCKER_TOKEN }} \
docker://localhost:5000/${{ steps.variables.outputs.ghimagepath }}:${{ github.event.inputs.tag }} \
docker://docker.io/${{ steps.variables.outputs.dkimagepath }}:${{ github.event.inputs.tag }}
skopeo copy --src-tls-verify=false --dest-creds ${{ secrets.DOCKER_USER }}:${{ secrets.DOCKER_TOKEN }} \
docker://localhost:5000/${{ steps.variables.outputs.ghimagepath }}:${{ github.event.inputs.tag }} \
docker://docker.io/${{ steps.variables.outputs.dkimagepath }}:latest
printf "\nPushing Quay Image...\n"
skopeo copy --src-tls-verify=false --dest-creds ${{ secrets.QUAY_USER }}:${{ secrets.QUAY_TOKEN }} \
docker://localhost:5000/${{ steps.variables.outputs.ghimagepath }}:${{ github.event.inputs.tag }} \
docker://quay.io/${{ steps.variables.outputs.qyimagepath }}:${{ github.event.inputs.tag }}
skopeo copy --src-tls-verify=false --dest-creds ${{ secrets.QUAY_USER }}:${{ secrets.QUAY_TOKEN }} \
docker://localhost:5000/${{ steps.variables.outputs.ghimagepath }}:${{ github.event.inputs.tag }} \
docker://quay.io/${{ steps.variables.outputs.qyimagepath }}:latest
else
printf "DryRun. Not pushing Git Tags. Printing commands...\n"
command=$(cat << EOF
printf "\nPushing GitHub Image...\n"
skopeo copy --src-tls-verify=false --dest-creds ${{ secrets.GH_USER }}:${{ secrets.GITHUB_TOKEN }} \
docker://localhost:5000/${{ steps.variables.outputs.ghimagepath }}:${{ github.event.inputs.tag }} \
docker://ghcr.io/${{ steps.variables.outputs.ghimagepath }}:${{ github.event.inputs.tag }}
skopeo copy --src-tls-verify=false --dest-creds ${{ secrets.GH_USER }}:${{ secrets.GITHUB_TOKEN }} \
docker://localhost:5000/${{ steps.variables.outputs.ghimagepath }}:${{ github.event.inputs.tag }} \
docker://ghcr.io/${{ steps.variables.outputs.ghimagepath }}:latest
printf "\nPushing DockerHub Image...\n"
skopeo copy --src-tls-verify=false --dest-creds ${{ secrets.DOCKER_USER }}:${{ secrets.DOCKER_TOKEN }} \
docker://localhost:5000/${{ steps.variables.outputs.ghimagepath }}:${{ github.event.inputs.tag }} \
docker://docker.io/${{ steps.variables.outputs.dkimagepath }}:${{ github.event.inputs.tag }}
skopeo copy --src-tls-verify=false --dest-creds ${{ secrets.DOCKER_USER }}:${{ secrets.DOCKER_TOKEN }} \
docker://localhost:5000/${{ steps.variables.outputs.ghimagepath }}:${{ github.event.inputs.tag }} \
docker://docker.io/${{ steps.variables.outputs.dkimagepath }}:latest
printf "\nPushing Quay Image...\n"
skopeo copy --src-tls-verify=false --dest-creds ${{ secrets.QUAY_USER }}:${{ secrets.QUAY_TOKEN }} \
docker://localhost:5000/${{ steps.variables.outputs.ghimagepath }}:${{ github.event.inputs.tag }} \
docker://quay.io/${{ steps.variables.outputs.qyimagepath }}:${{ github.event.inputs.tag }}
skopeo copy --src-tls-verify=false --dest-creds ${{ secrets.QUAY_USER }}:${{ secrets.QUAY_TOKEN }} \
docker://localhost:5000/${{ steps.variables.outputs.ghimagepath }}:${{ github.event.inputs.tag }} \
docker://quay.io/${{ steps.variables.outputs.qyimagepath }}:latest
EOF
)
printf "%s\n" "${command}"
fi
- name: Stop the Local Container Registry
run: podman stop registry