From de8e2c25614b2bbb8996bfe20192ae074ea7ee21 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 20 Apr 2026 11:28:48 +0800 Subject: [PATCH] Run Dependabot on Composer Packages --- .github/dependabot.yml | 10 ++++++- .github/workflows/coding-standards.yml | 38 +++++++++++++++++++++++--- .github/workflows/tests.yml | 38 +++++++++++++++++++++++--- 3 files changed, 77 insertions(+), 9 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 410f5b7..5c3cf2f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,4 +5,12 @@ updates: - package-ecosystem: "github-actions" directory: "/" schedule: - interval: "weekly" \ No newline at end of file + interval: "weekly" + + - package-ecosystem: "composer" + directory: "/" + schedule: + interval: "daily" + allow: + - dependency-type: "production" + versioning-strategy: "increase" \ No newline at end of file diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index acf9a3e..85d7b23 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -11,6 +11,29 @@ on: - main jobs: + dependabot-metadata: + # Name. + name: Dependabot Metadata + + # Virtual Environment to use. + # @see: https://github.com/actions/virtual-environments + runs-on: ubuntu-latest + + # Don't run if the PR is not from Dependabot. + if: github.actor == 'dependabot[bot]' + + # Outputs. + outputs: + package-ecosystem: ${{ steps.metadata.outputs.package-ecosystem }} + + # Steps to fetch Dependabot metadata. + steps: + - name: Fetch Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v2 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + tests: # Name. name: Coding Standards / WordPress ${{ matrix.wp-versions }} / PHP ${{ matrix.php-versions }} @@ -19,10 +42,17 @@ jobs: # @see: https://github.com/actions/virtual-environments runs-on: ubuntu-latest - # Don't run if the PR is from Dependabot, as it doesn't have access to the repository's secrets. - # Dependabot also only checks for GitHub action dependencies, so it's not necessary to run - # Plugin tests. - if: github.actor != 'dependabot[bot]' + # Requieres the dependabot-metadata job to have run successfully. + needs: [dependabot-metadata] + + # Always allow non-Dependabot PRs and pushes. + # For Dependabot PRs, only run when the update is for composer (skip github-actions updates). + if: | + always() && + ( + github.actor != 'dependabot[bot]' || + needs.dependabot-metadata.outputs.package-ecosystem == 'composer' + ) # Environment Variables. # Accessible by using ${{ env.NAME }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f5ca0aa..baf7ebb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,6 +11,29 @@ on: - main jobs: + dependabot-metadata: + # Name. + name: Dependabot Metadata + + # Virtual Environment to use. + # @see: https://github.com/actions/virtual-environments + runs-on: ubuntu-latest + + # Don't run if the PR is not from Dependabot. + if: github.actor == 'dependabot[bot]' + + # Outputs. + outputs: + package-ecosystem: ${{ steps.metadata.outputs.package-ecosystem }} + + # Steps to fetch Dependabot metadata. + steps: + - name: Fetch Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v2 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + tests: # Name. name: ${{ matrix.test-groups }} / WordPress ${{ matrix.wp-versions }} / PHP ${{ matrix.php-versions }} @@ -19,10 +42,17 @@ jobs: # @see: https://github.com/actions/virtual-environments runs-on: ubuntu-latest - # Don't run if the PR is from Dependabot, as it doesn't have access to the repository's secrets. - # Dependabot also only checks for GitHub action dependencies, so it's not necessary to run - # Plugin tests. - if: github.actor != 'dependabot[bot]' + # Requieres the dependabot-metadata job to have run successfully. + needs: [dependabot-metadata] + + # Always allow non-Dependabot PRs and pushes. + # For Dependabot PRs, only run when the update is for composer (skip github-actions updates). + if: | + always() && + ( + github.actor != 'dependabot[bot]' || + needs.dependabot-metadata.outputs.package-ecosystem == 'composer' + ) # Environment Variables. # Accessible by using ${{ env.NAME }}