2022-05-17 01:47:17 +00:00
|
|
|
name: Highlight templates and hooks changes
|
|
|
|
on: pull_request
|
|
|
|
jobs:
|
|
|
|
analyze:
|
|
|
|
name: Check pull request changes to highlight
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
outputs:
|
|
|
|
results: ${{ steps.results.outputs.results }}
|
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install prerequisites
|
|
|
|
run: |
|
2022-10-02 21:52:42 +00:00
|
|
|
npm install -g pnpm
|
2022-08-16 01:21:52 +00:00
|
|
|
npm -g i @wordpress/env@5.1.0
|
2022-09-10 21:55:53 +00:00
|
|
|
pnpm install --filter code-analyzer --filter cli-core
|
2022-05-17 01:47:17 +00:00
|
|
|
- name: Run analyzer
|
|
|
|
id: run
|
2022-09-15 21:21:42 +00:00
|
|
|
working-directory: tools/code-analyzer
|
2022-08-22 04:29:59 +00:00
|
|
|
run: |
|
2022-10-25 21:36:46 +00:00
|
|
|
HEAD_REF=$(git rev-parse HEAD)
|
|
|
|
version=$(pnpm run analyzer major-minor "$HEAD_REF" "plugins/woocommerce/woocommerce.php" | tail -n 1)
|
|
|
|
pnpm run analyzer "$HEAD_REF" $version -o "github"
|
2022-05-17 01:47:17 +00:00
|
|
|
- name: Print results
|
|
|
|
id: results
|
2022-06-08 21:25:49 +00:00
|
|
|
run: echo "::set-output name=results::${{ steps.run.outputs.templates }}${{ steps.run.outputs.wphooks }}${{ steps.run.outputs.schema }}${{ steps.run.outputs.database }}"
|
2022-05-17 01:47:17 +00:00
|
|
|
comment:
|
2022-06-30 19:12:34 +00:00
|
|
|
name: Add comment to highlight changes
|
2022-05-17 01:47:17 +00:00
|
|
|
needs: analyze
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
steps:
|
|
|
|
- name: Find Comment
|
|
|
|
uses: peter-evans/find-comment@v2
|
|
|
|
id: find-comment
|
|
|
|
with:
|
|
|
|
issue-number: ${{ github.event.number }}
|
2022-06-08 21:25:49 +00:00
|
|
|
body-includes: New hook, template, or database changes in this PR
|
2022-05-17 01:47:17 +00:00
|
|
|
- name: Add comment
|
|
|
|
if: ${{ needs.analyze.outputs.results && (steps.find-comment.outputs.comment-id == '') }}
|
|
|
|
uses: actions/github-script@v5
|
|
|
|
with:
|
2022-09-12 01:14:55 +00:00
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
2022-05-17 01:47:17 +00:00
|
|
|
script: |
|
|
|
|
github.rest.issues.createComment({
|
|
|
|
issue_number: context.issue.number,
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
2022-06-08 21:25:49 +00:00
|
|
|
body: '## New hook, template, or database changes in this PR${{ needs.analyze.outputs.results }}'
|
2022-05-17 01:47:17 +00:00
|
|
|
})
|
|
|
|
- name: Update comment
|
|
|
|
if: ${{ needs.analyze.outputs.results && steps.find-comment.outputs.comment-id }}
|
|
|
|
uses: actions/github-script@v5
|
|
|
|
with:
|
2022-09-12 01:14:55 +00:00
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
2022-05-17 01:47:17 +00:00
|
|
|
script: |
|
|
|
|
github.rest.issues.updateComment({
|
|
|
|
comment_id: ${{ steps.find-comment.outputs.comment-id }},
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
2022-06-08 21:25:49 +00:00
|
|
|
body: '## New hook, template, or database changes in this PR${{ needs.analyze.outputs.results }}'
|
2022-05-17 01:47:17 +00:00
|
|
|
})
|
|
|
|
- name: Delete comment
|
|
|
|
if: ${{ !needs.analyze.outputs.results && steps.find-comment.outputs.comment-id }}
|
2022-06-08 21:25:49 +00:00
|
|
|
uses: actions/github-script@v5
|
2022-05-17 01:47:17 +00:00
|
|
|
with:
|
2022-09-12 01:14:55 +00:00
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
2022-06-08 21:25:49 +00:00
|
|
|
script: |
|
|
|
|
github.rest.issues.deleteComment({
|
|
|
|
comment_id: ${{ steps.find-comment.outputs.comment-id }},
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo
|
|
|
|
})
|
2022-05-17 01:47:17 +00:00
|
|
|
- name: Add label
|
|
|
|
if: ${{ needs.analyze.outputs.results }}
|
|
|
|
uses: actions/github-script@v5
|
|
|
|
with:
|
2022-09-12 01:14:55 +00:00
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
2022-05-17 01:47:17 +00:00
|
|
|
script: |
|
|
|
|
github.rest.issues.addLabels({
|
|
|
|
issue_number: context.issue.number,
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
labels: ['release: highlight']
|
|
|
|
})
|
|
|
|
- name: Remove label
|
|
|
|
if: ${{ !needs.analyze.outputs.results }}
|
|
|
|
continue-on-error: true
|
|
|
|
uses: actions/github-script@v5
|
|
|
|
with:
|
2022-09-12 01:14:55 +00:00
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
2022-05-17 01:47:17 +00:00
|
|
|
script: |
|
|
|
|
github.rest.issues.removeLabel({
|
|
|
|
issue_number: context.issue.number,
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
name: ['release: highlight']
|
|
|
|
})
|