Fix TypeScript errors blocking CI, split Docker publish into native amd64/arm64 jobs with manifest merge, and add npm cache mounts.
100 lines
2.8 KiB
YAML
100 lines
2.8 KiB
YAML
name: Publish Docker image
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
env:
|
|
IMAGE_NAME: pichost
|
|
|
|
jobs:
|
|
build:
|
|
if: ${{ !contains(github.event.head_commit.message, '[skip docker]') }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- platform: linux/amd64
|
|
runner: ubuntu-latest
|
|
suffix: amd64
|
|
- platform: linux/arm64
|
|
runner: ubuntu-24.04-arm
|
|
suffix: arm64
|
|
runs-on: ${{ matrix.runner }}
|
|
env:
|
|
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ env.DOCKERHUB_USERNAME }}
|
|
password: ${{ env.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Resolve version
|
|
id: version
|
|
run: |
|
|
if [ "${{ github.ref_type }}" = "tag" ]; then
|
|
echo "value=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "value=dev" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Build and push platform image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
platforms: ${{ matrix.platform }}
|
|
tags: |
|
|
${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.value }}-${{ matrix.suffix }}
|
|
cache-from: type=gha,scope=${{ matrix.suffix }}
|
|
cache-to: type=gha,mode=max,scope=${{ matrix.suffix }}
|
|
|
|
merge:
|
|
if: ${{ !contains(github.event.head_commit.message, '[skip docker]') }}
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
steps:
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ env.DOCKERHUB_USERNAME }}
|
|
password: ${{ env.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Resolve version
|
|
id: version
|
|
run: |
|
|
if [ "${{ github.ref_type }}" = "tag" ]; then
|
|
echo "value=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "value=dev" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Create multi-arch manifest
|
|
run: |
|
|
IMAGE="${DOCKERHUB_USERNAME}/${IMAGE_NAME}"
|
|
VERSION="${{ steps.version.outputs.value }}"
|
|
docker buildx imagetools create \
|
|
-t "${IMAGE}:${VERSION}" \
|
|
-t "${IMAGE}:latest" \
|
|
"${IMAGE}:${VERSION}-amd64" \
|
|
"${IMAGE}:${VERSION}-arm64"
|