Publish docker images to GHCR #199
This file contains hidden or 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: 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: | |
name: build native | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
- ubuntu-24.04-arm | |
platform: | |
- aarch64-linux-gnu | |
- aarch64-linux-musl | |
- aarch64-mingw-ucrt | |
- 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: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: "3.3" | |
bundler-cache: true | |
- name: Fetch docker buildx layer cache | |
uses: actions/cache@v4 | |
with: | |
path: tmp/build-cache-${{ runner.arch }} | |
key: ${{ runner.os }}-on-${{ runner.arch }}-${{ matrix.platform }}-buildx-${{ github.sha }} | |
restore-keys: ${{ runner.os }}-on-${{ runner.arch }}-${{ matrix.platform }}-buildx | |
enableCrossOsArchive: true | |
- name: Change docker to a cache-able driver | |
run: | | |
docker buildx create --driver docker-container --use | |
bundle exec rake build:${{ matrix.platform }} RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,dest=tmp/build-cache-new" | |
- name: Show docker images | |
run: docker images | |
- name: Update and prune docker buildx layer cache | |
run: | | |
rm -rf tmp/build-cache-${{ runner.arch }} | |
mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }} | |
push: | |
name: push | |
needs: build | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- aarch64-linux-gnu | |
- aarch64-linux-musl | |
- aarch64-mingw-ucrt | |
- 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@v4 | |
- name: Use X64 cache from primary pipeline | |
uses: actions/cache/restore@v4 | |
with: | |
path: tmp/build-cache-X64 | |
key: ${{ runner.os }}-on-X64-${{ matrix.platform }}-buildx-${{ github.sha }} | |
restore-keys: ${{ runner.os }}-on-X64-${{ matrix.platform }}-buildx | |
enableCrossOsArchive: true | |
- name: Use ARM64 cache from primary pipeline | |
uses: actions/cache/restore@v4 | |
with: | |
path: tmp/build-cache-ARM64 | |
key: ${{ runner.os }}-on-ARM64-${{ matrix.platform }}-buildx-${{ github.sha }} | |
restore-keys: ${{ runner.os }}-on-ARM64-${{ matrix.platform }}-buildx | |
enableCrossOsArchive: true | |
fail-on-cache-miss: true | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: "3.3" | |
bundler-cache: true | |
- uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{github.actor}} | |
password: ${{secrets.GITHUB_TOKEN}} | |
- name: Use cache and push docker image | |
env: | |
RCD_IMAGE_VERSION: snapshot | |
RCD_DOCKER_BUILD: docker buildx build --cache-from=type=local,src=tmp/build-cache-X64 --cache-from=type=local,src=tmp/build-cache-ARM64 --cache-to=type=local,dest=tmp/build-cache-new | |
run: | | |
docker buildx create --driver docker-container --use | |
bundle exec rake release:${{matrix.platform}} |