Skip to content

Commit 3b56676

Browse files
committed
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.
1 parent 595494e commit 3b56676

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ on:
1414

1515
jobs:
1616
xmllint:
17+
# Don't run the cron job on forks.
18+
if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }}
19+
1720
name: 'Check XML'
1821
runs-on: ubuntu-latest
1922

@@ -46,6 +49,9 @@ jobs:
4649
run: diff -B ./PHPCompatibilityJoomla/ruleset.xml <(xmllint --format "./PHPCompatibilityJoomla/ruleset.xml")
4750

4851
test:
52+
# Don't run the cron job on forks.
53+
if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }}
54+
4955
needs: xmllint
5056
runs-on: ubuntu-latest
5157

0 commit comments

Comments
 (0)