From 21b00b7bed3745b7657cb5e053332183796cc2c3 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 4 Aug 2025 16:21:21 +0200 Subject: [PATCH] GH Actions: improve "don't run on forks" condition Remove the condition containing a hard-coded repository name in favour of a more generic condition which should safeguard that the cron job doesn't run on forks just the same. --- .github/workflows/happy-new-year.yml | 2 +- .github/workflows/validate.yml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/happy-new-year.yml b/.github/workflows/happy-new-year.yml index 58ff9041fc..2e36842916 100644 --- a/.github/workflows/happy-new-year.yml +++ b/.github/workflows/happy-new-year.yml @@ -28,7 +28,7 @@ jobs: update-year-in-test: runs-on: ubuntu-latest # Don't run the cron job on forks. - if: ${{ github.event_name != 'schedule' || github.repository == 'PHPCSStandards/PHP_CodeSniffer' }} + if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }} name: "Happy New Year" steps: diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index f898515291..3bc0ebe7eb 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest # Don't run the cronjob in this workflow on forks. - if: github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository_owner == 'PHPCSStandards') + if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }} steps: - name: Checkout code @@ -48,7 +48,7 @@ jobs: runs-on: ubuntu-latest # Don't run the cronjob in this workflow on forks. - if: github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository_owner == 'PHPCSStandards') + if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }} steps: - name: Checkout code @@ -92,7 +92,7 @@ jobs: runs-on: ubuntu-latest # Don't run the cronjob in this workflow on forks. - if: github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository_owner == 'PHPCSStandards') + if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }} env: XMLLINT_INDENT: ' ' @@ -131,7 +131,7 @@ jobs: yamllint: name: 'Lint Yaml' # Don't run the cronjob in this workflow on forks. - if: github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository_owner == 'PHPCSStandards') + if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }} uses: PHPCSStandards/.github/.github/workflows/reusable-yamllint.yml@main with: @@ -140,13 +140,13 @@ jobs: markdownlint: name: 'Lint Markdown' # Don't run the cronjob in this workflow on forks. - if: github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository_owner == 'PHPCSStandards') + if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }} uses: PHPCSStandards/.github/.github/workflows/reusable-markdownlint.yml@main remark: name: 'QA Markdown' # Don't run the cronjob in this workflow on forks. - if: github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository_owner == 'PHPCSStandards') + if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }} uses: PHPCSStandards/.github/.github/workflows/reusable-remark.yml@main