Files
sencho/.github/workflows/docker-preview.yml
T
dependabot[bot] 22512fd14b chore(deps): bump the all-actions group across 1 directory with 7 updates (#1597)
Bumps the all-actions group with 7 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) | `4.1.0` | `4.2.0` |
| [github/codeql-action/init](https://github.com/github/codeql-action) | `4.36.2` | `4.37.0` |
| [github/codeql-action/autobuild](https://github.com/github/codeql-action) | `4.36.2` | `4.37.0` |
| [github/codeql-action/analyze](https://github.com/github/codeql-action) | `4.36.2` | `4.37.0` |
| [docker/login-action](https://github.com/docker/login-action) | `4.2.0` | `4.4.0` |
| [docker/metadata-action](https://github.com/docker/metadata-action) | `6.1.0` | `6.2.0` |
| [github/codeql-action/upload-sarif](https://github.com/github/codeql-action) | `4.36.2` | `4.37.0` |



Updates `docker/setup-buildx-action` from 4.1.0 to 4.2.0
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5...bb05f3f5519dd87d3ba754cc423b652a5edd6d2c)

Updates `github/codeql-action/init` from 4.36.2 to 4.37.0
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/8aad20d150bbac5944a9f9d289da16a4b0d87c1e...99df26d4f13ea111d4ec1a7dddef6063f76b97e9)

Updates `github/codeql-action/autobuild` from 4.36.2 to 4.37.0
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/8aad20d150bbac5944a9f9d289da16a4b0d87c1e...99df26d4f13ea111d4ec1a7dddef6063f76b97e9)

Updates `github/codeql-action/analyze` from 4.36.2 to 4.37.0
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/8aad20d150bbac5944a9f9d289da16a4b0d87c1e...99df26d4f13ea111d4ec1a7dddef6063f76b97e9)

Updates `docker/login-action` from 4.2.0 to 4.4.0
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/650006c6eb7dba73a995cc03b0b2d7f5ca915bee...af1e73f918a031802d376d3c8bbc3fe56130a9b0)

Updates `docker/metadata-action` from 6.1.0 to 6.2.0
- [Release notes](https://github.com/docker/metadata-action/releases)
- [Commits](https://github.com/docker/metadata-action/compare/80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9...dc802804100637a589fabce1cb79ff13a1411302)

Updates `github/codeql-action/upload-sarif` from 4.36.2 to 4.37.0
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/8aad20d150bbac5944a9f9d289da16a4b0d87c1e...99df26d4f13ea111d4ec1a7dddef6063f76b97e9)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: 4.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
- dependency-name: docker/metadata-action
  dependency-version: 6.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
- dependency-name: docker/setup-buildx-action
  dependency-version: 4.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
- dependency-name: github/codeql-action/analyze
  dependency-version: 4.37.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
- dependency-name: github/codeql-action/autobuild
  dependency-version: 4.37.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
- dependency-name: github/codeql-action/init
  dependency-version: 4.37.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
- dependency-name: github/codeql-action/upload-sarif
  dependency-version: 4.37.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-07-08 14:07:47 -04:00

193 lines
7.1 KiB
YAML

name: Publish PR Preview Image
# ---------------------------------------------------------------------------
# Preview build vs integration (dev) vs release
# ---------------------------------------------------------------------------
# Maintainer-triggered Docker Hub images for external validation BEFORE a PR
# merges. Testers pull saelix/sencho:pr-<N> without GHCR credentials.
#
# Preview (this file) Integration (docker-dev.yml)
# --------------------- ---------------------------
# trigger: workflow_dispatch trigger: push to main
# registry: Docker Hub only registry: GHCR only
# image: saelix/sencho image: ghcr.io/.../sencho-dev
# tags: :pr-<N>, :preview-<sha> tags: :dev, :dev-<sha>
# signing / SBOM / Release: no signing / SBOM / Release: no
# approval gate: preview environment approval gate: none
#
# Release tags (latest, semver), cosign, SBOM/VEX, and GitHub Releases are
# RELEASE-ONLY in docker-publish.yml. Preview tags never use latest or semver.
# ---------------------------------------------------------------------------
on:
workflow_dispatch:
inputs:
pr_number:
description: 'PR number to build and publish (tags pr-N and preview-sha)'
required: true
type: number
concurrency:
group: docker-preview-pr-${{ inputs.pr_number }}
cancel-in-progress: true
permissions:
contents: read
jobs:
push_preview_image:
name: Build and push preview image to Docker Hub
runs-on: ubuntu-latest
timeout-minutes: 30
# DOCKERHUB_USERNAME and DOCKERHUB_TOKEN live in the `preview` environment
# (same Hub repo as production, but no release approval gate). Copy both
# secrets from the production environment when bootstrapping preview.
environment: preview
steps:
- name: Validate PR number
env:
PR_NUMBER: ${{ inputs.pr_number }}
run: |
set -euo pipefail
if ! [[ "$PR_NUMBER" =~ ^[0-9]+$ ]] || [ "$PR_NUMBER" -lt 1 ]; then
echo "pr_number must be a positive integer"
exit 1
fi
- name: Resolve pull request
id: pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ inputs.pr_number }}
run: |
set -euo pipefail
pr_json=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}")
state=$(echo "$pr_json" | jq -r '.state')
head_sha=$(echo "$pr_json" | jq -r '.head.sha')
if [ "$state" != "open" ]; then
echo "PR #${PR_NUMBER} is not open (state=${state})"
exit 1
fi
echo "head_sha=${head_sha}" >> "$GITHUB_OUTPUT"
echo "Building PR #${PR_NUMBER} at ${head_sha}"
- name: Check out the repo
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: refs/pull/${{ inputs.pr_number }}/head
- name: Set up QEMU
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
- name: Compute daily apk cache bust value
id: apk-bust
run: echo "date=$(date -u +%Y-%m-%d)" >> "$GITHUB_OUTPUT"
- name: Log in to Docker Hub
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6
with:
images: saelix/sencho
tags: |
type=raw,value=pr-${{ inputs.pr_number }}
type=sha,prefix=preview-,format=short
- name: Validate preview tags before publish
env:
TAGS: ${{ steps.meta.outputs.tags }}
PR_NUMBER: ${{ inputs.pr_number }}
run: |
set -euo pipefail
if [ -z "${TAGS// }" ]; then
echo "No tags generated for publish"
exit 1
fi
while IFS= read -r full_ref; do
[ -n "$full_ref" ] || continue
tag="${full_ref##*:}"
if [ "$tag" = "latest" ]; then
echo "Refusing to publish reserved tag: latest"
exit 1
fi
if [[ "$tag" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || [[ "$tag" =~ ^[0-9]+\.[0-9]+$ ]]; then
echo "Refusing to publish semver-like tag: ${tag}"
exit 1
fi
if [ "$tag" = "dev" ] || [[ "$tag" == dev-* ]]; then
echo "Refusing to publish dev integration tag: ${tag}"
exit 1
fi
if [[ "$tag" == "pr-${PR_NUMBER}" ]]; then
continue
fi
if [[ "$tag" =~ ^preview-[0-9a-f]+$ ]]; then
continue
fi
echo "Refusing to publish unexpected tag: ${tag}"
exit 1
done <<< "$TAGS"
- name: Build preview image for pre-publish scan (amd64, loaded)
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7
with:
context: .
push: false
load: true
platforms: linux/amd64
tags: localhost/sencho:preview-scan
cache-from: type=gha
build-args: |
APK_CACHE_BUST=${{ steps.apk-bust.outputs.date }}
- name: Scan preview image for vulnerabilities (Trivy)
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
image-ref: localhost/sencho:preview-scan
exit-code: '1'
severity: 'CRITICAL,HIGH'
format: 'table'
trivy-config: trivy.yaml
- name: Smoke test preview image (pre-publish)
run: |
set -euo pipefail
docker run --rm --entrypoint sh localhost/sencho:preview-scan -c \
'docker --version && docker compose version'
docker run -d --name sencho-preview-smoke -p 1852:1852 localhost/sencho:preview-scan
trap 'docker logs sencho-preview-smoke 2>&1 || true; docker rm -f sencho-preview-smoke >/dev/null 2>&1 || true' EXIT
for i in $(seq 1 30); do
if curl -fsS http://localhost:1852/api/health >/dev/null 2>&1; then
echo "Container healthy after ${i}s"
curl -s http://localhost:1852/api/health
exit 0
fi
sleep 1
done
echo "FAILED: /api/health did not become ready within 30s"
exit 1
- name: Build and push preview image
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
APK_CACHE_BUST=${{ steps.apk-bust.outputs.date }}