-
Notifications
You must be signed in to change notification settings - Fork 4.2k
101 lines (85 loc) · 5.12 KB
/
php-changes-detection.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: OPTIONAL - Confirm if PHP changes require backporting to WordPress Core
on:
pull_request:
types: [opened, synchronize]
jobs:
detect_php_changes:
name: Detect PHP changes
runs-on: ubuntu-latest
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
steps:
- name: Check out code
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
- name: Get changed PHP files
id: changed-files-php
uses: tj-actions/changed-files@03334d095e2739fa9ac4034ec16f66d5d01e9eba # v44.5.1
with:
files: |
lib/**
packages/**/*.php
phpunit/**
- name: List all changed files
if: steps.changed-files-php.outputs.any_changed == 'true'
id: list-changed-php-files
run: |
echo "Changed files:"
formatted_change_list=""
for file in ${{ steps.changed-files-php.outputs.all_changed_files }}; do
echo "$file was changed"
formatted_change_list+="<br>:grey_question: $file"
done
formatted_change_list+="<br>"
echo "formatted_change_list=$formatted_change_list" >> $GITHUB_OUTPUT
- name: Find Comment
uses: peter-evans/find-comment@v3
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: '<!-- pr-contains-php-changes -->'
- name: Create comment
if: steps.find-comment.outputs.comment-id == '' && steps.changed-files-php.outputs.any_changed == 'true'
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
<!-- pr-contains-php-changes -->
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.
If so, it is recommended to create a [new Trac ticket](https://core.trac.wordpress.org/newticket) and submit a pull request to the [WordPress Core GitHub repository](https://github.com/WordPress/wordpress-develop) soon after this pull request is merged.
If you're unsure, you can always ask for help in the #core-editor channel in [WordPress Slack](https://make.wordpress.org/chat/).
Thank you! :heart:
<details>
<summary>View changed files</summary>
${{ steps.list-changed-php-files.outputs.formatted_change_list }}
</details>
- name: Update comment
if: steps.find-comment.outputs.comment-id != '' && steps.changed-files-php.outputs.any_changed == 'true'
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
<!-- pr-contains-php-changes -->
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.
If so, it is recommended to create a [new Trac ticket](https://core.trac.wordpress.org/newticket) and submit a pull request to the [WordPress Core GitHub repository](https://github.com/WordPress/wordpress-develop) soon after this pull request is merged.
If you're unsure, you can always ask for help in the #core-editor channel in [WordPress Slack](https://make.wordpress.org/chat/).
Thank you! :heart:
<details>
<summary>View changed files</summary>
${{ steps.list-changed-php-files.outputs.formatted_change_list }}
</details>
- name: Update comment
if: steps.find-comment.outputs.comment-id != '' && steps.changed-files-php.outputs.any_changed != 'true'
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
<!-- pr-contains-php-changes -->
This pull request changed or added PHP files in previous commits, but none have been detected in the latest commit.
Thank you! :heart: