Skip to content

Improve CI error extraction for buildx #16

Improve CI error extraction for buildx

Improve CI error extraction for buildx #16

name: Build Miningcore image (multi-arch)
on:
workflow_dispatch:
push:
branches: [main]
paths:
- "willitmod-dev-dgb/images/miningcore/**"
- ".github/workflows/miningcore-image.yml"
permissions:
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout app store repo
uses: actions/checkout@v4
- name: Checkout upstream Miningcore source
uses: actions/checkout@v4
with:
repository: oliverw/miningcore
path: _vendor/miningcore
fetch-depth: 1
- name: Copy Dockerfile into build context
run: |
cp willitmod-dev-dgb/images/miningcore/Dockerfile _vendor/miningcore/Dockerfile
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Read image tag
id: tag
run: |
echo "tag=$(cat willitmod-dev-dgb/images/miningcore/VERSION)" >> "$GITHUB_OUTPUT"
- name: Build and push (plain progress)
env:
TAG: ${{ steps.tag.outputs.tag }}
run: |
set -euo pipefail
set -x
if ! docker buildx build \
--progress=plain \
--platform linux/amd64,linux/arm64 \
-f ./_vendor/miningcore/Dockerfile \
-t ghcr.io/willitmod/miningcore:${TAG} \
--push \
./_vendor/miningcore 2>&1 | tee /tmp/buildx.log; then
# GitHub limits annotation size; keep this short and focused.
tail_msg="$(tail -n 80 /tmp/buildx.log | sed -e 's/%/%25/g' -e 's/\r/%0D/g' -e 's/$/%0A/g' | tr -d '\n')"
err_msg="$(grep -Ei '(^|[^a-z])error:|^ERROR:' /tmp/buildx.log | tail -n 80 | sed -e 's/%/%25/g' -e 's/\r/%0D/g' -e 's/$/%0A/g' | tr -d '\n')"
echo "::error title=buildx errors (last matches)::${err_msg}"
echo "::error title=buildx tail (last 80 lines)::${tail_msg}"
exit 1
fi