Skip to content

Build Docker image

Build Docker image #97

Workflow file for this run

name: Build Docker image
on:
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 }}-${{ matrix.ubuntu_version }}-${{ github.event.inputs.ARCH }}
runs-on: ubuntu-latest
strategy:
matrix:
ubuntu_version:
- jammy
- focal
- bionic
steps:
- uses: actions/checkout@v4
- name: Show parameters
run: |
echo "RUBY_VERSION=${{ github.event.inputs.RUBY_VERSION }}"
echo "ARCH=${{ github.event.inputs.ARCH }}"
echo "LATEST=${{ github.event.inputs.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.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- 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
run: |
GHCR_TOKEN=${{ secrets.GHCR_TOKEN }}
echo $GHCR_TOKEN | docker login ghcr.io -u owner --password-stdin
- name: Push image to GitHub Container Registry
run: docker push ghcr.io/${{ github.repository_owner }}/ruby --all-tags
if: ${{ github.event.inputs.NOPUSH == 'false' }}