Skip to content

https://github.blog/changelog/2024-03-07-github-actions-all-actions-w… #55

https://github.blog/changelog/2024-03-07-github-actions-all-actions-w…

https://github.blog/changelog/2024-03-07-github-actions-all-actions-w… #55

Workflow file for this run

name: build and push containers to GHCR.io
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
directory: [ api, cli ]
platform: [ linux/amd64, linux/arm64 ]
steps:
- name: checkout repo
uses: actions/checkout@v4
- name: setup docker buildx
uses: docker/setup-buildx-action@v3
# with:
# buildkitd-flags: --debug
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Create a variable with platform '${{ matrix.platform }}' value
run: echo "PLATFORM=${{ matrix.platform }}" >> $GITHUB_ENV
- name: Swap / for - in '${{ matrix.platform }}' and create local_platform variable
id: local_platform
run: |
LOCAL_PLATFORM="${PLATFORM//\//-}"
echo "LOCAL_PLATFORM=${LOCAL_PLATFORM}" >> $GITHUB_ENV
echo "local_platform=${LOCAL_PLATFORM}" >> $GITHUB_STATE
- name: Cache Docker layers
uses: actions/cache@v3
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE20: true
with:
path: /tmp/.buildx-cache--${{ steps.local_platform.outputs.local_platform }}-${{ matrix.directory }}
# key: ${{ runner.os }}-buildx-${{ github.sha }}
key: ${{ runner.os }}-buildx
restore-keys: |
${{ runner.os }}-buildx
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./${{ matrix.directory }}
push: true
tags: ghcr.io/${{ github.repository_owner }}/hamframe-${{ matrix.directory }}:latest
platforms: ${{ matrix.platform }}
cache-from: type=local,src=/tmp/.buildx-cache--${{ steps.local_platform.outputs.local_platform }}-${{ matrix.directory }}
cache-to: type=local,dest=/tmp/.buildx-cache--${{ steps.local_platform.outputs.local_platform }}-${{ matrix.directory }}