Skip to content

Commit f8c5d03

Browse files
author
James Amner
authored
Merge pull request #322 from boxuk/workflow-trigggers
[BWP-122] Triggering the Test Workflows
2 parents 83707fa + f33af06 commit f8c5d03

File tree

10 files changed

+133
-58
lines changed

10 files changed

+133
-58
lines changed

.github/workflows/all-checks.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,26 @@ on:
66
workflows: ["Update WP Deps"]
77
types:
88
- completed
9-
109

1110
jobs:
1211
enforce-all-checks:
1312
runs-on: ubuntu-latest
1413
permissions:
1514
checks: read
1615
steps:
16+
- name: Checkout
17+
uses: boxuk/wp-checkout-deps-auto-update@main
18+
id: checkout-deps
19+
if: github.event_name == 'workflow_run'
20+
1721
- name: GitHub Checks
1822
uses: poseidon/[email protected]
1923
with:
20-
token: ${{ secrets.GITHUB_TOKEN }}
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Mark Check Outcome
27+
if: github.event_name == 'workflow_run'
28+
uses: boxuk/mark-check-status@main
29+
with:
30+
status: ${{ job.status }}
31+
pr-head-sha: ${{ steps.checkout-deps.outputs.pr-head-sha }}

.github/workflows/packages.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ jobs:
2626
target_repo: "wp-consent-management"
2727
- local_path: "email-tld-checker"
2828
target_repo: "wordpress-email-tld-checker"
29-
- local_path: "deps-auto-update"
29+
- local_path: "action-deps-auto-update"
3030
target_repo: "wp-deps-auto-update"
31-
- local_path: "checkout-deps-auto-update"
32-
target_repo: "wp-checkout-deps-auto-update"
31+
- local_path: "action-checkout-pr"
32+
target_repo: "checkout-pr"
33+
- local_path: "action-mark-check-status"
34+
target_repo: "mark-check-status"
3335
- local_path: "feature-flags"
3436
target_repo: "wp-feature-flags"
3537

.github/workflows/tests-js.yml

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,10 @@ jobs:
3737
if: github.event_name != 'workflow_run'
3838

3939
- name: Checkout
40-
uses: boxuk/wp-checkout-deps-auto-update@main
40+
uses: boxuk/checkout-pr@main
4141
id: checkout-deps
4242
if: github.event_name == 'workflow_run'
43-
with:
44-
workflow_run_id: ${{ github.event.workflow_run.id }}
45-
46-
- name: Mark Check as Pending
47-
if: github.event_name == 'workflow_run'
48-
env:
49-
GH_TOKEN: ${{ github.token }}
50-
run: |
51-
gh api repos/${{ github.repository }}/statuses/${{ steps.checkout-deps.outputs.pr-head-sha }} \
52-
-f state=pending \
53-
-f description="JS Quality Tests are in progress" \
54-
-f context="JS Quality Tests"
55-
43+
5644
- name: Setup Node
5745
uses: actions/setup-node@v4
5846
with:
@@ -70,24 +58,10 @@ jobs:
7058
- name: Build
7159
run: npm run build
7260

73-
- name: Mark Check as Success
74-
if: github.event_name == 'workflow_run' && success()
75-
env:
76-
GH_TOKEN: ${{ github.token }}
77-
run: |
78-
gh api repos/${{ github.repository }}/statuses/${{ steps.checkout-deps.outputs.pr-head-sha }} \
79-
-f state=success \
80-
-f target_url=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} \
81-
-f description="JS Quality Tests completed successfully" \
82-
-f context="JS Quality Tests"
83-
84-
- name: Mark Check as Failure
85-
if: github.event_name == 'workflow_run' && failure()
86-
env:
87-
GH_TOKEN: ${{ github.token }}
88-
run: |
89-
gh api repos/${{ github.repository }}/statuses/${{ steps.checkout-deps.outputs.pr-head-sha }} \
90-
-f state=failure \
91-
-f target_url=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} \
92-
-f description="JS Quality Tests failed" \
93-
-f context="JS Quality Tests"
61+
- name: Mark Check Outcome
62+
if: github.event_name == 'workflow_run'
63+
uses: boxuk/mark-check-status@main
64+
with:
65+
status: ${{ job.status }}
66+
pr-head-sha: ${{ steps.checkout-deps.outputs.pr-head-sha }}
67+

packages/checkout-deps-auto-update/action.yml renamed to packages/action-checkout-pr/action.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
name: Checkout WP Deps Branch
22
description: Checkout a branch for the WP Deps update action
3-
4-
inputs:
5-
workflow_run_id:
6-
description: 'The ID of the workflow run that triggered this action'
7-
required: true
83

94
outputs:
105
pr-head-sha:
@@ -23,7 +18,7 @@ runs:
2318
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
2419
owner: context.repo.owner,
2520
repo: context.repo.repo,
26-
run_id: ${{ inputs.workflow_run_id }},
21+
run_id: ${{ github.event.workflow_run.id }},
2722
});
2823
2924
if ( allArtifacts.data.total_count == 0 || allArtifacts.data.artifacts.length == 0 ) {
@@ -61,4 +56,11 @@ runs:
6156
- name: Checkout
6257
uses: actions/checkout@v4
6358
with:
64-
ref: ${{ env.PR_HEAD_SHA }}
59+
ref: ${{ steps.parse-pr-number.outputs.PR_HEAD_SHA }}
60+
61+
- name: Mark Check Pending
62+
uses: boxuk/mark-check-status@main
63+
with:
64+
status: "pending"
65+
pr-head-sha: ${{ steps.parse-pr-number.outputs.PR_HEAD_SHA }}
66+

packages/checkout-deps-auto-update/readme.md renamed to packages/action-checkout-pr/readme.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This is a simple GitHub Worklfow to checkout the PR the `boxuk/wp-deps-auto-upda
44

55
## Usage
66

7-
You'll need to use the `boxuk/wp-checkout-deps-auto-update` action to setup your workflow if the event is triggered by `workflow_run`. We need the `worfklow_run_id` to pull the relevant PR number.
7+
You'll need to use the `boxuk/checkout-pr` action to setup your workflow if the event is triggered by `workflow_run`. We need the `worfklow_run_id` to pull the relevant PR number.
88

99
```yml
1010
# Other config...
@@ -25,12 +25,18 @@ jobs:
2525
if: github.event_name != 'workflow_run'
2626

2727
- name: Checkout
28-
uses: boxuk/wp-checkout-deps-auto-update@main
28+
uses: boxuk/checkout-pr@main
29+
id: checkout-deps
2930
if: github.event_name == 'workflow_run'
30-
with:
31-
workflow_run_id: ${{ github.event.workflow_run.id }}
32-
33-
# next steps...
31+
32+
# Run Tests or whatever is needed...
33+
34+
- name: Mark Check Outcome
35+
if: github.event_name == 'workflow_run'
36+
uses: boxuk/mark-check-status@main
37+
with:
38+
status: ${{ job.status }}
39+
pr-head-sha: ${{ steps.checkout-deps.outputs.pr-head-sha }}
3440
```
3541
3642
## Contributing
File renamed without changes.

packages/deps-auto-update/readme.md renamed to packages/action-deps-auto-update/readme.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
4343
This will save the PR number created, so you can use it later for triggering tests etc.
4444
45-
For any other tests etc that you may need to have completed upon creation of this PR, you can then use the `boxuk/wp-checkout-deps-auto-update` action to setup your tests.
45+
For any other tests etc that you may need to have completed upon creation of this PR, you can then use the `boxuk/wp-checkout-pr` action to setup your tests.
4646

4747
```yml
4848
# Other config...
@@ -63,12 +63,18 @@ jobs:
6363
if: github.event_name != 'workflow_run'
6464
6565
- name: Checkout
66-
uses: boxuk/wp-checkout-deps-auto-update@main
66+
uses: boxuk/checkout-pr@main
67+
id: checkout-deps
6768
if: github.event_name == 'workflow_run'
68-
with:
69-
workflow_run_id: ${{ github.event.workflow_run.id }}
7069
71-
# next steps...
70+
# Run Tests or whatever is needed...
71+
72+
- name: Mark Check Outcome
73+
if: github.event_name == 'workflow_run'
74+
uses: boxuk/mark-check-status@main
75+
with:
76+
status: ${{ job.status }}
77+
pr-head-sha: ${{ steps.checkout-deps.outputs.pr-head-sha }}
7278
```
7379

7480
# Setting up your Project for WP Packages
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Mark Check Status
2+
description: Marks a check status for a given PR
3+
4+
inputs:
5+
status:
6+
description: 'The status to set'
7+
required: true
8+
default: 'pending'
9+
pr-head-sha:
10+
description: 'The SHA of the head of the PR'
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Set Check Status
16+
shell: bash
17+
env:
18+
GH_TOKEN: ${{ github.token }}
19+
run: |
20+
gh api repos/${{ github.repository }}/statuses/${{ inputs.pr-head-sha }} \
21+
-f state=${{ inputs.status }} \
22+
-f target_url=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} \
23+
-f context="${{ github.workflow }}" \
24+
-f description="${{ github.workflow }}"
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# WordPress Deps Auto Updater - Checkout
2+
3+
This is a simple GitHub Worklfow to mark the state of a status-check that's been triggered via the `workflow_run` trigger.
4+
5+
## Usage
6+
7+
You'll need to use the `boxuk/checkout-pr` action to setup your workflow if the event is triggered by `workflow_run`. We need the `worfklow_run_id` to pull the relevant PR number.
8+
9+
```yml
10+
# Other config...
11+
on:
12+
pull_request: # For all PRs
13+
workflow_run: # For WP Updates
14+
workflows: ["Update WP Deps"]
15+
types:
16+
- completed
17+
18+
jobs:
19+
test:
20+
runs-on: ubuntu-latest
21+
name: Test
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
if: github.event_name != 'workflow_run'
26+
27+
- name: Checkout
28+
uses: boxuk/checkout-pr@main
29+
id: checkout-deps
30+
if: github.event_name == 'workflow_run'
31+
32+
# Run Tests or whatever is needed...
33+
34+
- name: Mark Check Outcome
35+
if: github.event_name == 'workflow_run'
36+
uses: boxuk/mark-check-status@main
37+
with:
38+
status: ${{ job.status }}
39+
pr-head-sha: ${{ steps.checkout-deps.outputs.pr-head-sha }}
40+
```
41+
42+
## Contributing
43+
44+
Please do not submit any Pull Requests here. They will be closed.
45+
---
46+
47+
Please submit your PR here instead: https://github.com/boxuk/wp-packages
48+
49+
This repository is what we call a "subtree split": a read-only subset of that main repository.
50+
We're looking forward to your PR there!

0 commit comments

Comments
 (0)