-
Notifications
You must be signed in to change notification settings - Fork 29
98 lines (84 loc) · 3.08 KB
/
build.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
name: Build Docker image
on:
repository_dispatch:
types:
- build
workflow_dispatch:
inputs:
RUBY_VERSION:
description: The version of Ruby to be build
required: true
default: master
ARCH:
description: Which architecture amd64 or arm64 do you want to build? (The default is amd64)
type: choice
options:
- amd64
- arm64
default: amd64
required: true
LATEST:
description: Whether the latest tag should be created
type: boolean
default: false
required: true
NOPUSH:
description: Do not push the images (for debugging)
type: boolean
default: false
required: true
jobs:
build:
name: ${{ github.event.inputs.RUBY_VERSION || github.event.client_payload.ruby_version }}-${{ matrix.ubuntu_version }}-${{ github.event.inputs.ARCH || github.event.client_payload.arch }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ubuntu_version:
- noble
- jammy
- focal
steps:
- uses: actions/checkout@v4
- name: Store parameters to environmental variables
run: |
echo "RUBY_VERSION=${{ github.event.inputs.RUBY_VERSION || github.event.client_payload.ruby_version }}" >> $GITHUB_ENV
echo "ARCH=${{ github.event.inputs.ARCH || github.event.client_payload.arch }}" >> $GITHUB_ENV
echo "LATEST=${{ github.event.inputs.LATEST || github.event.client_payload.latest }}" >> $GITHUB_ENV
echo "NOPUSH=${{ github.event.inputs.NOPUSH }}" >> $GITHUB_ENV
- name: Show parameters
run: |
echo $RUBY_VERSION
echo $ARCH
echo $LATEST
echo $NOPUSH
- name: Build image
run: |
rake docker:build arch=${{ env.ARCH }} ruby_version=${{ env.RUBY_VERSION }} ubuntu_version=${{ matrix.ubuntu_version }} latest_tag=${{ env.LATEST }}
- name: Check image
run: |
docker images
if [[ "${{ env.ARCH }}" != "amd64" ]]; then
ARCH_SUFFIX=-${{ env.ARCH }}
fi
docker run rubylang/ruby:${{ env.RUBY_VERSION }}-${{ matrix.ubuntu_version }}${ARCH_SUFFIX} ruby -v
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Push images to DockerHub
run: docker push rubylang/ruby --all-tags
if: ${{ env.NOPUSH == 'false' }}
- name: Renaming images
run: |
docker images rubylang/ruby --format='docker tag {{.Repository}}:{{.Tag}} ghcr.io/ruby/ruby:{{.Tag}}' | sh -ex
- name: Login GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USER }}
password: ${{ secrets.GHCR_ACCESS_TOKEN }}
- name: Push image to GitHub Container Registry
run: docker push ghcr.io/${{ github.repository_owner }}/ruby --all-tags
if: ${{ env.NOPUSH == 'false' }}