Skip to content

Commit

Permalink
feat: try running arm64 build actions on macos-latest runner
Browse files Browse the repository at this point in the history
  • Loading branch information
Yukaii committed Oct 29, 2024
1 parent f00df50 commit 0b0c889
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 55 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/build-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build Steps

on:
workflow_call:
inputs:
platform:
required: true
type: string

jobs:
build:
runs-on: ${{ inputs.platform == 'linux/arm64' && 'macos-latest' || 'ubuntu-latest' }}
steps:
-
name: Prepare
run: |
echo "PLATFORM_PAIR=${{ inputs.platform//\//- }}" >> $GITHUB_ENV
-
name: Checkout
uses: actions/checkout@v4
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
file: ./deployments/Dockerfile
platforms: ${{ inputs.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
build-args: |
RUNTIME=${{ github.event.inputs.runtime || 'hackmdio/runtime:16.20.2-35fe7e39' }}
BUILDPACK=${{ github.event.inputs.buildpack || 'hackmdio/buildpack:16.20.2-35fe7e39' }}
-
name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
-
name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
72 changes: 17 additions & 55 deletions .github/workflows/push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,73 +18,35 @@ env:
REGISTRY_IMAGE: hackmdio/hackmd

jobs:
build:
build-amd64:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
-
name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
-
name: Checkout
uses: actions/checkout@v4
name: Set Platform Variable
run: echo "PLATFORM_PAIR=linux-amd64" >> $GITHUB_ENV
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
name: Execute Build Steps
uses: ./.github/workflows/build-steps.yml
with:
images: ${{ env.REGISTRY_IMAGE }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
file: ./deployments/Dockerfile
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
build-args: |
RUNTIME=${{ github.event.inputs.runtime || 'hackmdio/runtime:16.20.2-35fe7e39' }}
BUILDPACK=${{ github.event.inputs.buildpack || 'hackmdio/buildpack:16.20.2-35fe7e39' }}
platform: linux/amd64

build-arm64:
runs-on: macos-latest
steps:
-
name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
name: Set Platform Variable
run: echo "PLATFORM_PAIR=linux-arm64" >> $GITHUB_ENV
-
name: Upload digest
uses: actions/upload-artifact@v4
name: Execute Build Steps
uses: ./.github/workflows/build-steps.yml
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
platform: linux/arm64

merge:
runs-on: ubuntu-latest
needs:
- build
- build-amd64
- build-arm64
steps:
-
name: Download digests
Expand Down

0 comments on commit 0b0c889

Please sign in to comment.