-
Notifications
You must be signed in to change notification settings - Fork 1
156 lines (143 loc) · 5.47 KB
/
docker-cicd-release.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
156
name: "Docker CI (image releaser)"
env:
# Change this to match GITHUB_REPOSITORY or any name you want.
# But please be reminded that Docker images only support
# lowercased letters as as long as there's an label called
# org.opencontainers.image.source.
repository: kubernetes-starter
namespace: code-server-boilerplates
namespace_dockerhub: codeserverboilerplates
on:
release:
type: [published]
jobs:
# For prereleases, push to beta tag.
publish-to-beta:
name: Release to beta
runs-on: "ubuntu-latest"
if: ${{ github.event.release.prerelease == "true" }}
steps:
- name: "Create checkmates"
uses: "actions/checkout@v2"
- name: Generate metadata for Docker builds
id: meta
uses: docker/metadata-action@v3
with:
images: |
${{ env.namespace_dockerhub }}/${{ env.repository }}
quay.io/${{ env.namespace }}/${{ env.repository }}
ghcr.io/${{ env.namespace }}/${{ env.repository }}
tags: |
type=semver,pattern={{version}}
type=raw,value=beta
flavor: |
latest=false
- name: Print out values
env:
METADATA_OUTPUTS: ${{ toJSON(steps.meta.outputs) }}
run: "echo '$METADATA_OUTPUTS'"
# Setup QEMU for multiarch builds
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# and of course, we need to setup Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: "image=moby/buildkit:master,network=host"
# repeat this for other registries you want to use
# especially the official Docker Hub Registry
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
# change the username into yours if not using our bot
username: RecapTimeBot
# you need to manually add our bot with write access if you use our PAT
password: ${{ secrets.GH_SERVICE_ACCOUNT_API_KEY }}
- name: Login to Red Hat Quay Container Registry
uses: docker/login-action@v1
with:
registry: quay.io
# change the username into yours if not using our bot
username: ${{ secrets.QUAYIO_USERNAME }}
# may not work on personal accounts if using our PAT
# we may try soon
password: ${{ secrets.QUAYIO_PASSWORD }}
- name: Build and push to GHCR + DockerHub and RHQC
id: image-build
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
context: .
platforms: linux/amd64
publish-to-stable:
name: Release to stable
runs-on: "ubuntu-latest"
if: ${{ github.event.release.prerelease != "true" }}
steps:
- name: "Create checkmates"
uses: "actions/checkout@v2"
- name: Generate metadata for Docker builds
id: meta
uses: docker/metadata-action@v3
with:
images: |
${{ env.namespace_dockerhub }}/${{ env.repository }}
quay.io/${{ env.namespace }}/${{ env.repository }}
ghcr.io/${{ env.namespace }}/${{ env.repository }}
tags: |
type=semver,pattern={{version}}
flavor: |
latest=true
- name: Print out values
env:
METADATA_OUTPUTS: ${{ toJSON(steps.meta.outputs) }}
run: "echo '$METADATA_OUTPUTS'"
# Setup QEMU for multiarch builds
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# and of course, we need to setup Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: "image=moby/buildkit:master,network=host"
# repeat this for other registries you want to use
# especially the official Docker Hub Registry
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
# change the username into yours if not using our bot
username: RecapTimeBot
# you need to manually add our bot with write access if you use our PAT
password: ${{ secrets.GH_SERVICE_ACCOUNT_API_KEY }}
- name: Login to Red Hat Quay Container Registry
uses: docker/login-action@v1
with:
registry: quay.io
# change the username into yours if not using our bot
username: ${{ secrets.QUAYIO_USERNAME }}
# may not work on personal accounts if using our PAT
# we may try soon
password: ${{ secrets.QUAYIO_PASSWORD }}
- name: Build and push to GHCR + DockerHub and RHQC
id: image-build
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
context: .
platforms: linux/amd64