Skip to content

Publish docker images to GHCR #103

Publish docker images to GHCR

Publish docker images to GHCR #103

name: Publish docker images to GHCR
concurrency:
group: "${{github.workflow}}-${{github.ref}}"
cancel-in-progress: true
on:
workflow_dispatch:
schedule:
- cron: "0 3 * * 3" # At 03:00 on Wednesday # https://crontab.guru/#0_3_*_*_3
jobs:
build:
strategy:
fail-fast: false
matrix:
platform:
- aarch64-linux-gnu
- aarch64-linux-musl
- arm-linux-gnu
- arm-linux-musl
- arm64-darwin
- jruby
- x64-mingw-ucrt
- x64-mingw32
- x86-linux-gnu
- x86-linux-musl
- x86-mingw32
- x86_64-darwin
- x86_64-linux-gnu
- x86_64-linux-musl
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use cache from primary pipeline
uses: actions/cache@v3
with:
path: tmp/build-cache
key: ${{runner.os}}-${{matrix.platform}}-buildx-${{github.sha}}
restore-keys: |
${{runner.os}}-${{matrix.platform}}-buildx
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1"
bundler-cache: true
- id: rcd_config
run: |
bundle exec ruby -e ' \
require "rake_compiler_dock"; \
print "image_name="; \
puts RakeCompilerDock::Starter.container_image_name(:platform => %q(${{matrix.platform}})); \
print "snapshot_name="; \
puts RakeCompilerDock::Starter.container_image_name(:platform => %q(${{matrix.platform}}), :version => %q(snapshot)); \
' | tee -a $GITHUB_OUTPUT
- name: Build docker image
env:
RCD_DOCKER_BUILD: docker buildx build --cache-from=type=local,src=tmp/build-cache --cache-to=type=local,dest=tmp/build-cache-new --load
run: |
docker buildx create --driver docker-container --use
bundle exec rake build:${{matrix.platform}}
# move build cache and remove outdated layers
rm -rf tmp/build-cache
mv tmp/build-cache-new tmp/build-cache
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- run: |
docker images
docker tag ${{steps.rcd_config.outputs.image_name}} ${{steps.rcd_config.outputs.snapshot_name}}
docker push ${{steps.rcd_config.outputs.snapshot_name}}