From cf909e11d3867bfb0f727f12d2759b7adbb4a9d3 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Wed, 9 Dec 2020 20:05:01 +0000 Subject: [PATCH] Build/Test Tools: Disable GitHub Action workflow runs triggered on `push` for forks and mirrors. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the current state, the workflows run regardless of the repository context. This results many needless workflow runs that waste resources. Workflow runs for private repositories are not free (accounts have a finite allotment of minutes for private repositories). This becomes problematic in private repositories that also mirror the WordPress develop repository, as any workflow runs will draw from a user’s or organization’s allotted action minutes. Without blanket disabling the workflow manually for all event triggers, or modifying the workflow files in the forked/mirrored repository, there is no way to tune when the workflows run. This change introduces a conditional statement into all GitHub Action workflows that prevents them from running on forked/mirrored repositories that are not `wordpress-develop`, except when a pull request is being submitted to that repository. The exception to this is the Welcome workflow that posts a helpful message to first time contributors to `wordpress-develop`. This message is specific to this repository, so should only run when a PR is submitted to that repository. See #50401. git-svn-id: https://develop.svn.wordpress.org/trunk@49781 602fd350-edb4-49c9-b593-d223f7449a82 --- .github/workflows/coding-standards.yml | 4 ++++ .github/workflows/end-to-end-tests.yml | 2 ++ .github/workflows/javascript-tests.yml | 2 ++ .github/workflows/php-compatibility.yml | 1 + .github/workflows/phpunit-tests.yml | 1 + .github/workflows/verify-npm-on-windows.yml | 2 ++ .github/workflows/welcome-new-contributors.yml | 1 + 7 files changed, 13 insertions(+) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index c6249f97de..1b9342e477 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -27,6 +27,8 @@ jobs: phpcs: name: PHP coding standards runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} + steps: - name: Checkout repository uses: actions/checkout@v2 @@ -85,8 +87,10 @@ jobs: jshint: name: JavaScript coding standards runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }} + steps: - name: Checkout repository uses: actions/checkout@v2 diff --git a/.github/workflows/end-to-end-tests.yml b/.github/workflows/end-to-end-tests.yml index 4ff702b4ef..ec7e2b970e 100644 --- a/.github/workflows/end-to-end-tests.yml +++ b/.github/workflows/end-to-end-tests.yml @@ -34,6 +34,8 @@ jobs: e2e-tests: name: E2E Tests runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} + steps: - name: Cancel previous runs of this workflow (pull requests only) if: ${{ github.event_name == 'pull_request' }} diff --git a/.github/workflows/javascript-tests.yml b/.github/workflows/javascript-tests.yml index 508717a08f..54ccc47931 100644 --- a/.github/workflows/javascript-tests.yml +++ b/.github/workflows/javascript-tests.yml @@ -23,6 +23,8 @@ jobs: test-js: name: QUnit Tests runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} + steps: - name: Cancel previous runs of this workflow (pull requests only) if: ${{ github.event_name == 'pull_request' }} diff --git a/.github/workflows/php-compatibility.yml b/.github/workflows/php-compatibility.yml index b2d45384e8..a3915189ab 100644 --- a/.github/workflows/php-compatibility.yml +++ b/.github/workflows/php-compatibility.yml @@ -27,6 +27,7 @@ jobs: php-comatibility: name: Check PHP compatibility runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} steps: - name: Checkout repository diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index 02f374e89a..d90a671ed2 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -35,6 +35,7 @@ jobs: setup-wordpress: name: Setup WordPress runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} steps: - name: Cancel previous runs of this workflow (pull requests only) diff --git a/.github/workflows/verify-npm-on-windows.yml b/.github/workflows/verify-npm-on-windows.yml index 2d4a9c4323..598e982fd7 100644 --- a/.github/workflows/verify-npm-on-windows.yml +++ b/.github/workflows/verify-npm-on-windows.yml @@ -24,6 +24,8 @@ jobs: test-npm: name: Tests NPM on Windows runs-on: windows-latest + if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} + steps: - name: Cancel previous runs of this workflow (pull requests only) if: ${{ github.event_name == 'pull_request' }} diff --git a/.github/workflows/welcome-new-contributors.yml b/.github/workflows/welcome-new-contributors.yml index 74c9118a81..2522a5c4c2 100644 --- a/.github/workflows/welcome-new-contributors.yml +++ b/.github/workflows/welcome-new-contributors.yml @@ -8,6 +8,7 @@ jobs: # Comments on a pull request when the author is a new contributor. post-welcome-message: runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/wordpress-develop' }} steps: - uses: bubkoo/welcome-action@v1