Build Docker image #115
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
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 }}" | |
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.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' }} |