From b4289753ded3c72a696ea6c2efd0de3114607fc8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 4 Aug 2025 17:29:15 +0200 Subject: [PATCH] GH Actions: don't run cron jobs on forks While workflows are disabled by default in forks, it is quite common for contributors to enable them to verify CI will pass before submitting a pull request. When enabling workflow runs in forks, it's "all or nothing". This means that: * All workflows which are only intended to be run on the canonical repo will also be enabled. These workflows will also often need access to repo-specific secrets and will typically fail when run from a fork. * Workflows which contain cron jobs will also be enabled. Depending on the type of account the contributor has, this can burn through their "CI minutes". This commit is based on a review of workflows containing cron jobs and disables running the jobs when a cron job is triggered in a fork. --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e78e54..39145a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,9 @@ on: jobs: xmllint: + # Don't run the cron job on forks. + if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }} + name: 'Check XML' runs-on: ubuntu-latest @@ -55,6 +58,9 @@ jobs: diff -B ./PHPCompatibilitySymfonyPolyfillPHP80/ruleset.xml <(xmllint --format "./PHPCompatibilitySymfonyPolyfillPHP80/ruleset.xml") test: + # Don't run the cron job on forks. + if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }} + needs: xmllint runs-on: ubuntu-latest