Skip to content

build

build #120

Workflow file for this run

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: Show parameters
run: |
echo "RUBY_VERSION=${{ github.event.inputs.RUBY_VERSION || github.event.client_payload.ruby_version }}"
echo "ARCH=${{ github.event.inputs.ARCH || github.event.client_payload.arch }}"
echo "LATEST=${{ github.event.inputs.LATEST || github.event.client_payload.latest }}"
echo "NOPUSH=${{ github.event.inputs.NOPUSH }}"
- name: Build image
run: |
rake docker:build arch=${{ github.event.inputs.arch }} ruby_version=${{ github.event.inputs.RUBY_VERSION }} ubuntu_version=${{ matrix.ubuntu_version }}
- name: Check image
run: |
docker images
if [[ "${{ github.event.inputs.ARCH }}" != "amd64" ]]; then
ARCH_SUFFIX=-${{ github.event.inputs.ARCH }}
fi
docker run rubylang/ruby:${{ github.event.inputs.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: ${{ github.event.inputs.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: ${{ github.event.inputs.NOPUSH == 'false' }}