Skip to content

ruby/ruby-docker-images/build_multiarch #17

ruby/ruby-docker-images/build_multiarch

ruby/ruby-docker-images/build_multiarch #17

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
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
GHCR_USER: ${{ secrets.GHCR_USER }}
GHCR_ACCESS_TOKEN: ${{ secrets.GHCR_ACCESS_TOKEN }}
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 }}${{ matrix.dev_suffix }}-${{ inputs.ubuntu_version }}-${{ matrix.arch }}-${{ github.sha }}
dev_suffix: ${{ matrix.dev_suffix }}
optflags: ''
cppflags: ''
debugflags: ''
steps:
- uses: actions/[email protected]
- 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
- uses: "./.github/actions/build_image"
with:
ruby_version: "${{ env.ruby_version }}"
nightly: "${{ env.nightly }}"
image_version_suffix: "${{ env.image_version_suffix }}${{ env.dev_suffix }}"
ubuntu_version: "${{ env.ubuntu_version }}"
tag_suffix: "${{ env.tag_suffix }}"
latest_tag: ${{ env.latest_tag }}
target: ${{ env.target }}
arch: "linux/${{ matrix.arch }}"
- uses: "./.github/actions/push_image"
if: "${{ env.push }}"
with:
ruby_version: "${{ env.ruby_version }}"
nightly: "${{ env.nightly }}"
image_version_suffix: "${{ env.image_version_suffix }}${{ env.dev_suffix }}"
ubuntu_version: "${{ env.ubuntu_version }}"
tag_suffix: "${{ env.tag_suffix }}"
- uses: "./.github/actions/push_image_by_tag"
if: "${{ env.push_tags }}"
with:
push_tags: "${{ env.push_tags }}"
deploy_multiarch:
strategy:
matrix:
registry_name: [ rubylang, ghcr.io/ruby ]
runs-on: ubuntu-latest
needs: build
env:
ruby_version: "${{ inputs.ruby_version }}"
ubuntu_version: "${{ inputs.ubuntu_version }}"
registry_name: "${{ matrix.registry_name }}"
steps:
- uses: actions/[email protected]
- name: Login to ${{ env.registry_name }}
run: |-
case x"${{ env.registry_name }}" in
xrubylang)
echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin
;;
xghcr.io/ruby)
echo $GHCR_ACCESS_TOKEN | docker login ghcr.io -u $GHCR_USER --password-stdin
;;
*)
echo "ERROR: Unknown registry_name parameter: $registry_name" >&2
exit 1
;;
esac
- name: Create manifest for ${{ env.registry_name }}
run: |-
rake docker:manifest:create \
registry_name="${{ env.registry_name }}" \
ruby_version="${{ env.ruby_version }}" \
ubuntu_version="${{ env.ubuntu_version }}" \
architectures="amd64 arm64" \
manifest_suffix=${{ github.sha }} \
latest_tag=true
rake docker:manifest:create \
registry_name="${{ env.registry_name }}" \
ruby_version="${{ env.ruby_version }}" \
ubuntu_version="${{ env.ubuntu_version }}" \
architectures="amd64 arm64" \
image_version_suffix=-dev \
manifest_suffix=${{ github.sha }}
- name: Push manifest to ${{ env.registry_name }}
run: |-
rake docker:manifest:push \
registry_name="${{ env.registry_name }}" \
ruby_version="${{ env.ruby_version }}" \
ubuntu_version="${{ env.ubuntu_version }}" \
latest_tag=true
rake docker:manifest:push \
registry_name="${{ env.registry_name }}" \
ruby_version="${{ env.ruby_version }}" \
ubuntu_version="${{ env.ubuntu_version }}" \
image_version_suffix=-dev