-
Notifications
You must be signed in to change notification settings - Fork 1
155 lines (144 loc) · 5.74 KB
/
Copy pathdocker-cicd-release.yml
File metadata and controls
155 lines (144 loc) · 5.74 KB
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: "Docker CI (image release)"
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: nodejs-starter
namespace: code-server-boilerplates
namespace_dockerhub: codeserverboilerplates
on:
release:
# After tagging a release from the command line, you need to create a new release
# for the releaser CI to trigger.
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 }}
# For prereleases, the tag name should be have a suffix, like -betaXX
tags: |
type=semver,pattern={{version}}
flavor: |
latest=false
# 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, might use
# an env or secrets way in the future
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: .
# arm64 can sometimes experience weird GnuTLS errors
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}}
# v0.2.x and above
type=semver,pattern={{major}}.{{minor}}
# disabled if major zero
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
flavor: |
latest=true
# 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: .
# arm64 can sometimes experience weird GnuTLS errors
platforms: linux/amd64