Skip to content

[TASK] Start the build when the official PHP images get a new PHP release - #640

Merged
htuscher merged 3 commits into
masterfrom
task/php-upstream-watch
Nov 19, 2026
Merged

htuscher merged 3 commits into
masterfrom
task/php-upstream-watch

Conversation

@htuscher

@htuscher htuscher commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

The nightly build (00:00 UTC, in practice often started hours later) picks up a PHP security release up to a day after the official php images have it. This adds .github/workflows/php-upstream.yaml, which closes that gap:

  • Every hour (17 * * * *) it reads PHP_VERSION (linux/amd64) of the image in the FROM line of each docker/php-official/<tag>/Dockerfile, and of webdevops/php-official:<tag> and webdevops/php-nginx:<tag>. It uses skopeo inspect --no-tags after skopeo login to Docker Hub with the existing secrets; no third-party action gets the token.
  • If one of ours differs or does not exist yet, it starts build.yaml on master with gh workflow run (the token of the run with actions: write). An image that cannot be read for any other reason (rate limit, network) is skipped with a warning, so it does not start a build.
  • It does not start a build while a build of master is running or queued. Pull request runs do not count, even from a fork's master branch.
  • Within 8 hours, it does not start a build if one that it started (actor github-actions[bot]) did not succeed, so a failing build is not restarted every hour. It also starts at most 3 builds in that time, in case a build succeeds and still leaves an image outdated. A successful build does not block the next one: the official images update their versions and variants at different times. Builds started by hand do not count. The nightly build is unaffected.
  • A rebuild of the official images without a new PHP version starts nothing; the nightly build covers that.
  • workflow_dispatch with dry-run only reports which tags are behind.
  • The file is written by hand; ci/console generate only writes build.yaml, so "Validate Automation" is unaffected.

A build started this way is a workflow_dispatch run, so it uses the build cache (no-cache is only set for schedule). The changed digest of the official base image invalidates every layer above it, so PHP is still the new one.

Documentation: docs/README.md (Platforms and updates) and CONTRIBUTING.md (Building in CI) describe the workflow.

Verification:

  • actionlint passed on the first version; it has not been run again since the review changes.
  • The step scripts were extracted from the YAML and checked with bash -n.
  • The compare step was run against a skopeo stub: up to date, outdated, missing tag of ours (manifest unknown), read error of ours, read error of the official image, official image without PHP_VERSION. Each case produced the expected messages and outdated output.
  • The start step was run against a gh stub that evaluates the --jq expressions with jq. Each scenario produced the expected result:
    • nothing running → start
    • push build running → wait
    • only a fork PR running → start
    • failed or cancelled bot build 1–2 h ago → wait
    • successful bot build 2 h ago → start
    • 3 bot builds in 8 h → wait
    • failed manual build → start
    • failed bot build 9 h ago → start
    • dry run → report only
  • Not tested: the real Docker Hub calls (anonymous rate limit), and that a run started with the run token has the actor github-actions[bot]. Run the workflow with dry-run after merging to see both.

…ease

The nightly build picks up a PHP security release only up to a day later.
php-upstream.yaml compares PHP_VERSION of the official base images with
webdevops/php-official and webdevops/php-nginx every hour and starts
build.yaml on master when one of ours is behind, unless a build is running
or one was started in the last 8 hours.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bi2Ta2LNVtJh8Cakewj8rJ
- Log in with skopeo instead of docker/login-action, so no third-party
  action receives the Docker Hub token (SonarCloud githubactions:S7637).
- skopeo inspect --no-tags: do not list every tag of each repository.
- Ignore pull_request runs when looking for a running build of master;
  --branch matches the head branch, which is master for many fork PRs.
- A tag of ours that does not exist yet starts the build; any other read
  error skips the image with a warning instead of starting a full build.
- Only builds this workflow started (actor github-actions[bot]) block the
  next one for 8 hours; builds started by hand no longer do.

Kanti commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Review follow-up, pushed as 1666bd7 ([TASK] Harden the PHP upstream check):

  • Docker Hub login without docker/login-action. The workflow now logs in with skopeo login --password-stdin into an auth file in $RUNNER_TEMP, and skopeo inspect reads it with --authfile. No third-party action receives the Docker Hub token anymore. This fixes the SonarCloud finding githubactions:S7637 (Security Rating C). The other finding, S7679 ($1 used directly), is fixed with local image=$1.
  • skopeo inspect --no-tags. Without it, skopeo lists every tag of each repository (thousands for library/php) on each of the 24 reads per run.
  • Pull requests no longer count as a running build of master. gh run list --branch matches the head branch, so a PR from the master branch of a fork counted as one. Runs with event == pull_request are now ignored.
  • A missing tag and a read error are handled differently. If one of our tags does not exist yet (manifest unknown), the workflow starts the build. Any other error reading one of our images skips that image with a warning, so a hiccup or a 429 no longer starts a full build. An unreadable official image, or one without PHP_VERSION, skips the tag as before, with the reason in the warning.
  • Only builds started by this workflow trigger the 8-hour cooldown. The cooldown now counts only workflow_dispatch runs of build.yaml whose actor is github-actions[bot], which is what the run token creates. A build started by hand no longer delays the next PHP release.
  • CONTRIBUTING.md describes the new behaviour.

Verification: I extracted the step scripts from the YAML and checked them with bash -n. I ran the compare step against a skopeo stub covering every case: up to date, outdated, missing tag, read error of ours, read error upstream, and upstream without PHP_VERSION. Each case produced the expected messages and outdated output. I checked both jq filters with jq against sample run lists (fork PR run, completed run, queued push run; bot vs. manual dispatch inside and outside the cooldown).

Not covered by these tests: the real Docker Hub calls and the actor of a dispatched run. Run the workflow with dry-run after merging to see them.


Generated by Claude Code

The cooldown blocked the next build for 8 hours after any build this
workflow started, also after a successful one. The official images
update their versions and variants at different times, so a tag that
was updated after the first build waited up to 8 hours.

Now only a build that did not succeed blocks the next one. As a safety
net, the workflow starts at most 3 builds within 8 hours, in case a
build succeeds and still leaves an image outdated.
@htuscher
htuscher merged commit d84dc1d into master Nov 19, 2026
4 checks passed
@sonarqubecloud

Copy link
Copy Markdown

@Kanti
Kanti deleted the task/php-upstream-watch branch November 19, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants