Back to packages

/workflows

Shared reusable GitHub Actions workflows for the myerscode organization

0Stars
0Forks
14Commits
v1.0.0Latest
MITLicense
Shell100.0%

myerscode/workflows

Shared, reusable GitHub Actions workflows for the myerscode organization.

Write CI once here, call it everywhere. Each workflow is a reusable workflow invoked with uses: from a consumer repo and pinned to a release tag.

Available workflows

WorkflowFilePurpose
Dependabot Auto-merge.github/workflows/dependabot-auto-merge.ymlApprove + auto-merge Dependabot PRs when checks pass and there are no conflicts
PHP Tests.github/workflows/php-tests.ymlPHPUnit across an OS + PHP-version matrix
Lint & Analyse.github/workflows/php-lint.ymlPint + PHPStan; fix: true auto-fixes and commits
Security Audit.github/workflows/php-security-audit.ymlcomposer audit
Code Coverage.github/workflows/php-coverage.ymlPHPUnit coverage + Codecov upload
PHP Release.github/workflows/php-release.ymlTag, changelog, GitHub release + CHANGELOG commit (CalVer or SemVer)
PHP Changelog.github/workflows/php-changelog.ymlRegenerate + commit CHANGELOG.md for a version on demand
Composer Normalize.github/workflows/composer-normalize.ymlcomposer normalize all composer.json (check or fix+commit)
Compile Assets.github/workflows/compile-assets.ymlnpm build + commit compiled assets (for the sites)
PR Hygiene.github/workflows/pr-hygiene.ymlNudge external draft / non-editable PRs; close uneditable ones
Issue Triage.github/workflows/issue-triage.ymlComment on issues when a label (e.g. help wanted) is applied

Usage

Add a workflow to a consumer repo (.github/workflows/ci.yml) that calls these. A full example lives in examples/consumer-ci.yml:

name: CI

on:
  push:
    branches: [ main, develop, feature/** ]
  pull_request:
    branches: [ main, develop, feature/** ]

permissions:
  contents: read

jobs:
  quality:
    uses: myerscode/workflows/.github/workflows/php-lint.yml@v1

  tests:
    uses: myerscode/workflows/.github/workflows/php-tests.yml@v1
    with:
      php-versions: "['8.5']"
      os: "['ubuntu-latest', 'macos-latest', 'windows-latest']"

  audit:
    uses: myerscode/workflows/.github/workflows/php-security-audit.yml@v1

  coverage:
    uses: myerscode/workflows/.github/workflows/php-coverage.yml@v1
    secrets:
      CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Inputs

Every workflow ships defaults that match current myerscode conventions (PHP 8.5; ctype, iconv, json, mbstring; composer install --prefer-dist --no-progress --no-interaction), so most repos can call them with no with: block. Override only what differs.

dependabot-auto-merge.yml

Approves and enables auto-merge on Dependabot PRs. GitHub completes the merge only once branch protection's required checks pass and the branch has no conflicts, so the "no conflicts" rule is enforced by GitHub itself.

Only one run proceeds at a time per repo (shared concurrency group, cancel-in-progress: false): if several Dependabot PRs open at once they are processed serially and none are dropped.

Grouped (multi-dependency) PRs are handled: Dependabot leaves update-type empty for a group, so the gate reads updated-dependencies-json and judges the PR by the highest bump in the group (e.g. a group containing a major bump is blocked under highest-auto-merge: minor). An unparsable group fails closed.

The caller must trigger on pull_request_target — see examples/consumer-dependabot-auto-merge.yml. Dependabot's pull_request token is read-only and has no secret access, so it cannot merge; pull_request_target runs in the base repo with a writable token. This workflow never checks out or runs PR code, so that is safe.

Repo prerequisites:

  • Settings → General → Allow auto-merge enabled.
  • Branch protection with required status checks on the default branch (else --auto merges immediately with nothing to gate on).
InputDefaultNotes
merge-methodsquashmerge, squash, or rebase
highest-auto-mergeminorpatch, minor, or major. Caps the semver bump that may auto-merge
approvetrueAlso submit an approving review
resolve-conflictsrecreateHow to unstick a PR that can't merge: rebase (fix behind only), recreate (also rebuild a conflicted branch), or off
ignore-indirecttrueJudge the semver cap against direct dependencies only, so a transitive (indirect) major pulled in alongside a direct minor/patch does not block auto-merge. false counts any bump

Handling stuck PRs

--auto completes a merge only once the branch is up to date and conflict-free. When a PR falls behind main or conflicts (common when several Dependabot PRs touch the same lockfile), the workflow reads its merge state and nudges Dependabot:

  • behind → comments @dependabot rebase
  • conflicted → comments @dependabot recreate (rebuilds the branch; resolve-conflicts: rebase instead leaves a note for a human)

To nudge PRs that are already stuck (outside a fresh workflow run), run:

scripts/kick-stuck-prs.sh myerscode/<repo>

Adding the workflow to another repo

scripts/add-auto-merge.sh myerscode/<repo> v1   # use develop while testing

It clones the repo, writes the caller workflow (and a starter dependabot.yml if none exists), stages the change, and prints the signed-commit + PR commands to run. It never commits or pushes to a protected branch for you.

php-tests.yml

InputDefault
php-versions['8.5'] (JSON array)
os['ubuntu-latest', 'macos-latest', 'windows-latest'] (JSON array)
extensionsctype, iconv, json, mbstring
composer-flags--prefer-dist --no-progress --no-interaction
test-commandvendor/bin/phpunit --testdox --no-coverage

php-lint.yml

InputDefault
php-version8.5
lint-commandvendor/bin/pint --test
analyse-commandvendor/bin/phpstan analyse --no-progress

php-security-audit.yml

InputDefault
php-version8.5
audit-commandcomposer audit

php-coverage.yml

Input / SecretDefault
php-version8.5
coverage-commandvendor/bin/phpunit --testdox --coverage-clover ./coverage.xml
coverage-file./coverage.xml
CODECOV_TOKEN (secret)required

Versioning

Consumers pin to a tag. Cut a release tag and move a floating major alias so repos can track @v1:

git tag -a v1.0.0 -m "v1.0.0"
git tag -f v1            # floating major alias
git push origin v1.0.0
git push -f origin v1

Pin to @v1 for automatic minor/patch updates, or to an exact @v1.0.0 for a frozen contract. Avoid @main in consumers — an unversioned change here would hit every repo at once.

License

MIT