1111 - main
1212
1313jobs :
14+ dependabot-metadata :
15+ # Name.
16+ name : Dependabot Metadata
17+
18+ # Virtual Environment to use.
19+ # @see: https://github.com/actions/virtual-environments
20+ runs-on : ubuntu-latest
21+
22+ # Don't run if the PR is not from Dependabot.
23+ if : github.actor == 'dependabot[bot]'
24+
25+ # Outputs.
26+ outputs :
27+ package-ecosystem : ${{ steps.metadata.outputs.package-ecosystem }}
28+
29+ # Steps to fetch Dependabot metadata.
30+ steps :
31+ - name : Fetch Dependabot metadata
32+ id : metadata
33+ uses : dependabot/fetch-metadata@v2
34+ with :
35+ github-token : " ${{ secrets.GITHUB_TOKEN }}"
36+
1437 tests :
1538 # Name.
1639 name : ${{ matrix.test-groups }} / WordPress ${{ matrix.wp-versions }} / PHP ${{ matrix.php-versions }}
@@ -19,10 +42,17 @@ jobs:
1942 # @see: https://github.com/actions/virtual-environments
2043 runs-on : ubuntu-latest
2144
22- # Don't run if the PR is from Dependabot, as it doesn't have access to the repository's secrets.
23- # Dependabot also only checks for GitHub action dependencies, so it's not necessary to run
24- # Plugin tests.
25- if : github.actor != 'dependabot[bot]'
45+ # Requieres the dependabot-metadata job to have run successfully.
46+ needs : [dependabot-metadata]
47+
48+ # Always allow non-Dependabot PRs and pushes.
49+ # For Dependabot PRs, only run when the update is for composer (skip github-actions updates).
50+ if : |
51+ always() &&
52+ (
53+ github.actor != 'dependabot[bot]' ||
54+ needs.dependabot-metadata.outputs.package-ecosystem == 'composer'
55+ )
2656
2757 # Environment Variables.
2858 # Accessible by using ${{ env.NAME }}
@@ -396,11 +426,16 @@ jobs:
396426 build-and-deploy :
397427 name : WordPress Playground
398428
399- # Require the tests workflow to have run successfully.
400- needs : tests
401-
402- # Only run on pull requests, not when merging to main branch
403- if : github.event_name == 'pull_request' && github.actor != 'dependabot[bot]'
429+ # Require the dependabot-metadata and tests workflows to have run successfully.
430+ needs : [dependabot-metadata, tests]
431+ if : |
432+ always() &&
433+ github.event_name == 'pull_request' &&
434+ needs.tests.result == 'success' &&
435+ (
436+ github.actor != 'dependabot[bot]' ||
437+ needs.dependabot-metadata.outputs.package-ecosystem == 'composer'
438+ )
404439
405440 # Virtual Environment to use.
406441 # @see: https://github.com/actions/virtual-environments
0 commit comments