From 5ee96ed3676845b3f32ca027ecb73c774502b46e Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 18 Sep 2025 05:41:46 +0200 Subject: [PATCH] GH Actions: add new "pinact" job In a previous PR, all action runners used in GH Actions workflows where "pinned" to precise versions for security reasons. However, that doesn't prevent new jobs, or changes to existing jobs, from being introduced which do not correctly pin action runners. This commit introduces a new GHA job which runs the `pinact` tooling via a reusable workflow as available since the `PHPCSStandards/.github` 1.3.0 release. Pinact is a tool which can be used to: * Update the action runner references in existing workflows to commit-hash "pinned" versions. * Verify that the commit hash to which an action runner is pinned is valid. * Verify that a "pinned" commit-hash matches the version number in the comment following the action runner reference. * Verify that a mandatory "minimum age" (`cooldown`) period is respected. The default `min-age` setting is 7 days. * Safeguard that any changes in workflows do not introduce new unpinned action runner references. The pinact action runner can also push a new commit to open PRs if the "verification"checks fail, however I do not think this is necessary at this time. The inline annotations in a PR and the failing build should be sufficient to prevent new issues from entering the workflows. Notes: * I've added a `.pinact.yaml` file. This is required for the reusable workflow to run, but also ensures that running the tool locally vs running it in CI will yield the same results. * In the configuration, I've set the "min-age" for dependencies to 3 days (default = 7) to be in line with the GitHub default `cooldown` setting. At a later point in time we may want to increase this number. This should be done in conjunction with the `cooldown` setting in the `dependabot.yml` configuration. Refs: * https://github.com/PHPCSStandards/.github/releases/tag/v1.3.0 * https://github.com/suzuki-shunsuke/pinact * https://github.com/suzuki-shunsuke/pinact#configuration * https://github.com/suzuki-shunsuke/pinact-action --- .github/workflows/qa.yml | 7 +++++++ .pinact.yaml | 8 ++++++++ 2 files changed, 15 insertions(+) create mode 100644 .pinact.yaml diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml index 3e6a6f1..1a2eeac 100644 --- a/.github/workflows/qa.yml +++ b/.github/workflows/qa.yml @@ -70,6 +70,13 @@ jobs: name: 'PHPStan' uses: PHPCSStandards/.github/.github/workflows/reusable-phpstan.yml@559f40470dbce9f7faeab31f82c0be7dfb93228e # v1.3.0 + pinact: + permissions: + contents: read # To clone the repo. + + name: 'Run Pinact' + uses: PHPCSStandards/.github/.github/workflows/reusable-pinact.yml@559f40470dbce9f7faeab31f82c0be7dfb93228e # v1.3.0 + yamllint: permissions: contents: read # To clone the repo. diff --git a/.pinact.yaml b/.pinact.yaml new file mode 100644 index 0000000..2816e56 --- /dev/null +++ b/.pinact.yaml @@ -0,0 +1,8 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/suzuki-shunsuke/pinact/refs/heads/main/json-schema/pinact.json +# pinact - https://github.com/suzuki-shunsuke/pinact + +version: 3 + +min_age: + value: 3 # Default is 7 days + always: true # Always check this, not just when updating pins.