-
Notifications
You must be signed in to change notification settings - Fork 809
186 lines (176 loc) · 6.47 KB
/
docker_publish.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: Docker Build & Push
on:
pull_request:
push:
branches:
- master
release:
types:
- released
jobs:
# This job exposes image_tag and push_enabled variables for other jobs.
# Other jobs depends on this. see needs: meta in other jobs.
meta:
if: github.repository == 'cadence-workflow/cadence'
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.determine-image-tag.outputs.image_tag }}
push_enabled: ${{ steps.determine-push.outputs.enabled }}
steps:
# this step determines the image tag based on the event that triggered the workflow.
# it sets the image_tag output variable to either "master" or the release version.
- name: Determine image tag
id: determine-image-tag
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
echo "image_tag=master" >> $GITHUB_OUTPUT
elif [[ "${{ github.event_name }}" == "release" ]]; then
echo "image_tag=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
else
echo "image_tag=test" >> $GITHUB_OUTPUT
fi
# This step determines if push is enabled based on the event that triggered the workflow. Push is disabled on pull requests.
- name: Determine if push is enabled
id: determine-push
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "enabled=false" >> $GITHUB_OUTPUT
else
echo "enabled=true" >> $GITHUB_OUTPUT
fi
push_server_image:
name: Push server image to Docker Hub
needs: meta
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to Docker Hub
if: ${{ needs.meta.outputs.push_enabled == 'true' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.CADENCE_SERVER_DOCKERHUB_USERNAME }}
password: ${{ secrets.CADENCE_SERVER_DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64, linux/arm64
build-args: TARGET=server
push: ${{ needs.meta.outputs.push_enabled == 'true' }}
tags: ubercadence/server:${{ needs.meta.outputs.image_tag }}
- name: Validate tag
run: |
echo "ubercadence/server:${{ needs.meta.outputs.image_tag }}"
push_server_auto_setup_image:
name: Push auto-setup image to Docker Hub
needs: meta
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to Docker Hub
if: ${{ needs.meta.outputs.push_enabled == 'true' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.CADENCE_SERVER_DOCKERHUB_USERNAME }}
password: ${{ secrets.CADENCE_SERVER_DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64, linux/arm64
build-args: TARGET=auto-setup
push: ${{ needs.meta.outputs.push_enabled == 'true' }}
tags: ubercadence/server:${{ needs.meta.outputs.image_tag }}-auto-setup
- name: Validate tag
run: |
echo "ubercadence/server:${{ needs.meta.outputs.image_tag }}-auto-setup"
push_cli_image:
name: Push CLI image to Docker Hub
needs: meta
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
if: ${{ needs.meta.outputs.push_enabled == 'true' }}
with:
username: ${{ secrets.CADENCE_SERVER_DOCKERHUB_USERNAME }}
password: ${{ secrets.CADENCE_SERVER_DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64, linux/arm64
build-args: TARGET=cli
push: ${{ needs.meta.outputs.push_enabled == 'true' }}
tags: ubercadence/cli:${{ needs.meta.outputs.image_tag }}
- name: Validate tag
run: |
echo "ubercadence/cli:${{ needs.meta.outputs.image_tag }}"
push_bench_image:
name: Push bench image to Docker Hub on master pushes
needs: meta
runs-on: ubuntu-latest
if: ${{ needs.meta.outputs.image_tag == 'master' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
if: ${{ needs.meta.outputs.push_enabled == 'true' }}
with:
username: ${{ secrets.CADENCE_SERVER_DOCKERHUB_USERNAME }}
password: ${{ secrets.CADENCE_SERVER_DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64, linux/arm64
build-args: TARGET=bench
tags: ubercadence/bench:master
push: ${{ needs.meta.outputs.push_enabled == 'true' }}
push_canary_image:
name: Push canary image to Docker Hub on master pushes
needs: meta
runs-on: ubuntu-latest
if: ${{ needs.meta.outputs.image_tag == 'master' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
if: ${{ needs.meta.outputs.push_enabled == 'true' }}
with:
username: ${{ secrets.CADENCE_SERVER_DOCKERHUB_USERNAME }}
password: ${{ secrets.CADENCE_SERVER_DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64, linux/arm64
build-args: TARGET=canary
tags: ubercadence/canary:master
push: ${{ needs.meta.outputs.push_enabled == 'true' }}