-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
192 lines (172 loc) · 5.96 KB
/
docker-image-dev-multi.yml
File metadata and controls
192 lines (172 loc) · 5.96 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
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
187
188
189
190
191
192
name: Multi-Arch Dev Build
on:
push:
branches:
- master
paths:
- 'src/**'
- 'misc/**'
workflow_dispatch:
inputs:
commit_hash:
description: 'Commit hash to build (optional)'
required: false
type: string
concurrency:
group: dev-build-${{ github.ref }}
cancel-in-progress: true
env:
IMAGE_NAME: airensoft/ovenmediaengine
SLACK_WEBHOOK_URL: ${{ secrets.ACTION_STATE_NOTIFICATION_SLACK_WEBHOOK_URL }}
jobs:
set-vars:
runs-on: ubuntu-22.04
outputs:
ref: ${{ steps.vars.outputs.ref }}
tag: ${{ steps.vars.outputs.tag }}
branch: ${{ steps.vars.outputs.branch }}
steps:
- id: vars
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
if [[ -n "${{ github.event.inputs.commit_hash }}" ]]; then
short_tag=$(echo "${{ github.event.inputs.commit_hash }}" | cut -c1-7)
echo "ref=${{ github.event.inputs.commit_hash }}" >> $GITHUB_OUTPUT
echo "tag=${short_tag}" >> $GITHUB_OUTPUT
echo "branch=manual" >> $GITHUB_OUTPUT
else
short_tag=$(echo "${{ github.sha }}" | cut -c1-7)
echo "ref=${{ github.sha }}" >> $GITHUB_OUTPUT
echo "tag=${short_tag}" >> $GITHUB_OUTPUT
echo "branch=manual-latest" >> $GITHUB_OUTPUT
fi
else
echo "ref=${{ github.sha }}" >> $GITHUB_OUTPUT
echo "tag=dev" >> $GITHUB_OUTPUT
echo "branch=dev" >> $GITHUB_OUTPUT
fi
build_amd64:
name: Build amd64 Image
runs-on: ubuntu-22.04
needs: set-vars
steps:
- name: Notify Start (amd64)
uses: slackapi/slack-github-action@v1.26.0
with:
payload: |
{
"branch": "${{ needs.set-vars.outputs.branch }}",
"tag": "${{ needs.set-vars.outputs.tag }} (amd64 by ${{ github.actor }})",
"state": "Started"
}
env:
SLACK_WEBHOOK_URL: ${{ env.SLACK_WEBHOOK_URL }}
- uses: actions/checkout@v4
with:
ref: ${{ needs.set-vars.outputs.ref }}
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push amd64 image
run: |
docker buildx build \
--platform linux/amd64 \
--output=type=image,push=true \
--tag ${{ env.IMAGE_NAME }}:${{ needs.set-vars.outputs.tag }}-amd64 \
.
- name: Notify Done (amd64)
if: always()
uses: slackapi/slack-github-action@v1.26.0
with:
payload: |
{
"branch": "${{ needs.set-vars.outputs.branch }}",
"tag": "${{ needs.set-vars.outputs.tag }} (amd64 by ${{ github.actor }})",
"state": "${{ job.status }}"
}
env:
SLACK_WEBHOOK_URL: ${{ env.SLACK_WEBHOOK_URL }}
build_arm64:
name: Build arm64 Image
runs-on: ubuntu-22.04-arm
needs: set-vars
steps:
- name: Notify Start (arm64)
uses: slackapi/slack-github-action@v1.26.0
with:
payload: |
{
"branch": "${{ needs.set-vars.outputs.branch }}",
"tag": "${{ needs.set-vars.outputs.tag }} (arm64 by ${{ github.actor }})",
"state": "Started"
}
env:
SLACK_WEBHOOK_URL: ${{ env.SLACK_WEBHOOK_URL }}
- uses: actions/checkout@v4
with:
ref: ${{ needs.set-vars.outputs.ref }}
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push arm64 image
run: |
docker buildx build \
--platform linux/arm64 \
--output=type=image,push=true \
--tag ${{ env.IMAGE_NAME }}:${{ needs.set-vars.outputs.tag }}-arm64 \
.
- name: Notify Done (arm64)
if: always()
uses: slackapi/slack-github-action@v1.26.0
with:
payload: |
{
"branch": "${{ needs.set-vars.outputs.branch }}",
"tag": "${{ needs.set-vars.outputs.tag }} (arm64 by ${{ github.actor }})",
"state": "${{ job.status }}"
}
env:
SLACK_WEBHOOK_URL: ${{ env.SLACK_WEBHOOK_URL }}
merge:
name: Merge and Push Manifest
runs-on: ubuntu-22.04
needs: [build_amd64, build_arm64, set-vars]
steps:
- name: Notify Start (Merge)
uses: slackapi/slack-github-action@v1.26.0
with:
payload: |
{
"branch": "${{ needs.set-vars.outputs.branch }}",
"tag": "${{ needs.set-vars.outputs.tag }} (merge by ${{ github.actor }})",
"state": "Started"
}
env:
SLACK_WEBHOOK_URL: ${{ env.SLACK_WEBHOOK_URL }}
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create and push manifest
run: |
docker buildx imagetools create \
--tag ${{ env.IMAGE_NAME }}:${{ needs.set-vars.outputs.tag }} \
${{ env.IMAGE_NAME }}:${{ needs.set-vars.outputs.tag }}-amd64 \
${{ env.IMAGE_NAME }}:${{ needs.set-vars.outputs.tag }}-arm64
- name: Notify Done (manifest)
if: always()
uses: slackapi/slack-github-action@v1.26.0
with:
payload: |
{
"branch": "${{ needs.set-vars.outputs.branch }}",
"tag": "${{ needs.set-vars.outputs.tag }} (merge by ${{ github.actor }})",
"state": "${{ job.status }}"
}
env:
SLACK_WEBHOOK_URL: ${{ env.SLACK_WEBHOOK_URL }}