-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Github workflow: add a PHP backport changes action #52096
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
01836ac
initial commit adding PHP changes action
ramonjd 9134f86
reverting PHP changes
ramonjd 65202fe
Updating message if exists and no PHP changes
ramonjd 9327e66
Remove comment-author (invalid prop)
ramonjd 3fabdd7
Replace comment, don't append
ramonjd 99ec579
Update php-changes-detection.yml
ramonjd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
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@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Get changed PHP files | ||
id: changed-files-php | ||
uses: tj-actions/changed-files@v37 | ||
with: | ||
files: | | ||
*.{php} | ||
lib/** | ||
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@v2 | ||
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@v3 | ||
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@v3 | ||
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@v3 | ||
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: |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this if we're already outputting all the changed files in the formatted list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left it there in case we need to debug the script's steps by eyeballing the CI logs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense!