mirror of
https://github.com/sethforprivacy/p2pool-docker.git
synced 2026-06-23 12:22:36 -04:00
Reliability (catch a bad image revision before prod): - Smoke-test the exact pushed digest in update-image-on-push.yml BEFORE the merge job tags it 'latest' (previously the prod artifact was never run). - Assert the p2pool banner reports the pinned P2POOL_BRANCH tag, and verify the container starts and stays up, instead of just sleeping 30s. Hardening: - Least-privilege 'permissions:' blocks (default contents: read; packages: write only on push/merge jobs; repo default token is currently write-all). - Concurrency groups (cancel superseded PR builds; serialize prod pushes). - persist-credentials: false on checkout; timeout-minutes on jobs. Build cache: - cache-to registry buildcache (mode=max, per-arch); read buildcache + latest. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
87 lines
2.9 KiB
YAML
87 lines
2.9 KiB
YAML
name: "Test build of image when Dockerfile is changed"
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- 'Dockerfile'
|
|
branches-ignore:
|
|
- main
|
|
pull_request:
|
|
paths:
|
|
- 'Dockerfile'
|
|
workflow_dispatch:
|
|
|
|
# Least-privilege default token (this workflow only reads the repo and pulls cache)
|
|
permissions:
|
|
contents: read
|
|
|
|
# Cancel superseded runs for the same ref to save CI minutes
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
GHCR_REPO: ghcr.io/${{ github.repository_owner }}/p2pool
|
|
|
|
jobs:
|
|
rebuild-container:
|
|
name: "Build image with cache"
|
|
timeout-minutes: 60
|
|
permissions:
|
|
contents: read
|
|
packages: read
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os:
|
|
- ubuntu-latest
|
|
- ubuntu-24.04-arm
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- name: Prepare platform matrix for arm64
|
|
if: runner.arch == 'ARM64'
|
|
run: |
|
|
echo "PLATFORM=linux/arm64" >> $GITHUB_ENV
|
|
echo "DIGEST_NAME=arm64" >> $GITHUB_ENV
|
|
- name: Prepare platform matrix for amd64
|
|
if: runner.arch == 'X64'
|
|
run: |
|
|
echo "PLATFORM=linux/amd64" >> $GITHUB_ENV
|
|
echo "DIGEST_NAME=amd64" >> $GITHUB_ENV
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v4.1.0
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Test build of image
|
|
id: build
|
|
uses: docker/build-push-action@v7.2.0
|
|
with:
|
|
push: false
|
|
load: true
|
|
platforms: ${{ env.PLATFORM }}
|
|
tags: p2pool:testing
|
|
cache-from: |
|
|
type=registry,ref=${{ env.GHCR_REPO }}:buildcache-${{ env.DIGEST_NAME }}
|
|
type=registry,ref=${{ env.GHCR_REPO }}:latest
|
|
- name: Verify reported version matches the pinned p2pool tag
|
|
run: |
|
|
set -euo pipefail
|
|
EXPECTED="$(awk -F= '/^ARG P2POOL_BRANCH=/{print $2; exit}' Dockerfile)"
|
|
echo "Expecting p2pool to report: ${EXPECTED}"
|
|
OUT="$(docker run --rm p2pool:testing --help 2>&1 || true)"
|
|
echo "${OUT}" | head -1
|
|
echo "${OUT}" | grep -q "${EXPECTED}" \
|
|
|| { echo "::error::p2pool banner does not contain expected tag ${EXPECTED}"; exit 1; }
|
|
- name: Verify the container starts and stays up
|
|
run: |
|
|
set -uo pipefail
|
|
CID="$(docker run -d p2pool:testing --wallet 468ydghFfthE3UTc53eF5MP9UyrMcUiAHP5kizVYJsej5XGaXBoAAEzUHCcUF7t3E3RrYAX8Rs1ujhBdcvMpZSbH8qkb55R)"
|
|
sleep 20
|
|
if [ "$(docker inspect -f '{{.State.Running}}' "$CID" 2>/dev/null || echo false)" != "true" ]; then
|
|
echo "::error::container exited early"; docker logs "$CID" 2>&1 || true
|
|
docker rm -f "$CID" >/dev/null 2>&1 || true; exit 1
|
|
fi
|
|
docker rm -f "$CID" >/dev/null 2>&1 || true
|