Bump docker/setup-buildx-action from 1 to 3 (#332) #286
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 and push docker images | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- "v*" | |
branches: | |
- "main" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
docker_images: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- ruby_target: x86_64-linux | |
- ruby_target: x86_64-linux-musl | |
- ruby_target: aarch64-linux | |
- ruby_target: aarch64-linux-musl | |
- ruby_target: arm-linux | |
- ruby_target: x86_64-darwin | |
- ruby_target: arm64-darwin | |
- ruby_target: x64-mingw32 | |
- ruby_target: x64-mingw-ucrt | |
# - ruby_target: x86-mingw32 | |
# - ruby_target: x86-linux | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set rb-sys version variable | |
id: vars | |
run: | | |
version="$(ruby -r $PWD/gem/lib/rb_sys/version.rb -e 'puts RbSys::VERSION')" | |
echo "rb-sys-version=$version" >> $GITHUB_OUTPUT | |
# Test the container | |
- uses: actions/checkout@v4 | |
with: | |
repository: "oxidize-rb/oxi-test" | |
path: "tmp/oxi-test" | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: "3.1" | |
- name: Login to Docker Hub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ secrets.DOCKER_HUB_USERNAME }}/${{ matrix.platform.ruby_target }} | |
flavor: | | |
latest=auto | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=sha,format=long | |
labels: | |
org.opencontainers.image.description=Image for building native Rust extensions for Ruby on ${{ matrix.platform.ruby_target }} | |
org.opencontainers.image.vendor=oxidize-rb | |
org.oxidize-rb.ruby.platform=${{ matrix.platform.ruby_target }} | |
- name: Docker build | |
uses: docker/build-push-action@v5 | |
with: | |
builder: ${{ steps.buildx.outputs.name }} | |
context: ./docker | |
file: ./docker/Dockerfile.${{ matrix.platform.ruby_target }} | |
platforms: linux/amd64 | |
load: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ matrix.platform.ruby_target }}:cache-${{ steps.vars.outputs.rb-sys-version }} | |
cache-to: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ matrix.platform.ruby_target }}:cache-${{ steps.vars.outputs.rb-sys-version }} | |
- name: Run tests | |
run: | | |
sudo chmod 777 tmp/oxi-test | |
cd tmp/oxi-test | |
gem install rb_sys | |
cargo update -p rb-sys | |
cargo update -p rb-sys-build | |
cargo update -p rb-sys-env | |
export RB_SYS_DOCK_UID=$(id -u) | |
export RB_SYS_DOCK_GID=$(id -g) | |
export RCD_IMAGE=${{ secrets.DOCKER_HUB_USERNAME }}/${{ matrix.platform.ruby_target }}:sha-${{ github.sha }} | |
rb-sys-dock --platform ${{ matrix.platform.ruby_target }} --build --version "sha-$GITHUB_SHA" | |
- name: Docker push | |
uses: docker/build-push-action@v5 | |
with: | |
builder: ${{ steps.buildx.outputs.name }} | |
context: ./docker | |
file: ./docker/Dockerfile.${{ matrix.platform.ruby_target }} | |
platforms: linux/amd64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ matrix.platform.ruby_target }}:cache-${{ steps.vars.outputs.rb-sys-version }} | |
cache-to: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ matrix.platform.ruby_target }}:cache-${{ steps.vars.outputs.rb-sys-version }} | |
- name: Docker Hub Description | |
uses: peter-evans/dockerhub-description@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
repository: rbsys/${{ matrix.platform.ruby_target }} | |
readme-filepath: ./readme.md | |
- name: Slack Noti on Failure | |
uses: 8398a7/action-slack@v3 | |
with: | |
status: ${{ job.status }} | |
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took,pullRequest | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
if: failure() |