-
Notifications
You must be signed in to change notification settings - Fork 29
191 lines (164 loc) · 5.93 KB
/
build_multiarch.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
187
188
189
190
191
name: ruby/ruby-docker-images/build_multiarch
on:
schedule:
- cron: '30 */12 * * *'
workflow_dispatch:
inputs:
ruby_version:
required: true
default: master
description: '"master" or version nunmber ("3.1.2")'
ubuntu_version:
required: false
default: jammy
jobs:
build:
strategy:
matrix:
dev_suffix: [ '', '-dev' ]
arch: ['amd64', 'arm64']
runs-on: ubuntu-latest
env:
nightly: false
push: false
ubuntu_version: "${{ inputs.ubuntu_version || 'jammy' }}"
ruby_version: "${{ inputs.ruby_version || 'master' }}"
image_version_suffix: ''
tag_suffix: "-${{ matrix.arch }}-${{ github.sha }}"
push_tags: ${{ inputs.ruby_version || 'master' }}${{ matrix.dev_suffix }}-${{ inputs.ubuntu_version || 'jammy' }}-${{ matrix.arch }}-${{ github.sha }}
dev_suffix: ${{ matrix.dev_suffix }}
optflags: ''
cppflags: ''
debugflags: ''
steps:
- uses: actions/[email protected]
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USER }}
password: ${{ secrets.GHCR_ACCESS_TOKEN }}
- run: |
if [ "${{ env.dev_suffix }}" = "-dev" ]; then
echo "target=development" >> $GITHUB_ENV
echo "latest_tag=false" >> $GITHUB_ENV
else
echo "target=ruby" >> $GITHUB_ENV
echo "latest_tag=true" >> $GITHUB_ENV
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build docker image
run: |-
rake docker:build ruby_version=${{ env.ruby_version }} \
ubuntu_version=${{ env.ubuntu_version }} \
arch=linux/${{ matrix.arch }} \
image_version_suffix=${{ env.image_version_suffix }}${{ env.dev_suffix }} \
nightly=${{ env.nightly }} \
tag_suffix=${{ env.tag_suffix }} \
target=${{ env.target }} \
latest_tag=${{ env.latest_tag }}
shell: bash
- name: List images
run: docker images
shell: bash
- name: Push docker image to rubylang
if: ${{ env.push }}
run: |-
rake docker:push ruby_version=${{ env.ruby_version }} \
ubuntu_version=${{ env.ubuntu_version }} \
image_version_suffix=${{ env.image_version_suffix }}${{ env.dev_suffix }} \
nightly=${{ env.nightly }} \
tag_suffix=${{ env.tag_suffix }} \
latest_tag=false \
registry_name=rubylang
shell: bash
- name: Push docker image to rubylang
if: "${{ env.push_tags }}"
run: |-
push_tags="${{ env.push_tags }}"
for tag in $push_tags; do
docker push rubylang/ruby:$tag
done
shell: bash
- name: Push docker image to ghcr.io/ruby
if: "${{ env.push_tags }}"
run: |-
push_tags="${{ env.push_tags }}"
for tag in $push_tags; do
docker tag rubylang/ruby:$tag ghcr.io/ruby/ruby:$tag
docker push ghcr.io/ruby/ruby:$tag
done
shell: bash
- uses: ruby/[email protected]
with:
payload: |
{
"attachments": [{
"text": "${{ job.status }}: ${{ matrix.arch }} ${{ matrix.dev_suffix }} <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>",
"color": "danger"
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()
deploy_multiarch:
strategy:
matrix:
registry_name: [ rubylang, ghcr.io/ruby ]
include:
- latest_tag: true
image_version_suffix: ''
- latest_tag: false
image_version_suffix: '-dev'
runs-on: ubuntu-latest
needs: build
env:
ruby_version: "${{ inputs.ruby_version || 'master' }}"
ubuntu_version: "${{ inputs.ubuntu_version || 'jammy' }}"
steps:
- uses: actions/[email protected]
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USER }}
password: ${{ secrets.GHCR_ACCESS_TOKEN }}
- name: Create manifest for ${{ matrix.registry_name }}
run: |-
rake docker:manifest:create \
registry_name="${{ matrix.registry_name }}" \
ruby_version="${{ env.ruby_version }}" \
ubuntu_version="${{ env.ubuntu_version }}" \
architectures="amd64 arm64" \
manifest_suffix=${{ github.sha }} \
latest_tag=${{ matrix.latest_tag }} \
image_version_suffix=${{ matrix.image_version_suffix }}
- name: Push manifest to ${{ matrix.registry_name }}
run: |-
rake docker:manifest:push \
registry_name="${{ matrix.registry_name }}" \
ruby_version="${{ env.ruby_version }}" \
ubuntu_version="${{ env.ubuntu_version }}" \
latest_tag=${{ matrix.latest_tag }} \
image_version_suffix=${{ matrix.image_version_suffix }}
- uses: ruby/[email protected]
with:
payload: |
{
"attachments": [{
"text": "${{ job.status }}: ${{ matrix.registry_name }} <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>",
"color": "danger"
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()