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: |
|
|
|
|
npm install -g pnpm@^6.24.2
|
2022-06-08 21:25:49 +00:00
|
|
|
npm -g i @wordpress/env
|
2022-05-17 01:47:17 +00:00
|
|
|
pnpm install
|
2022-06-09 21:40:07 +00:00
|
|
|
pnpm build:feature-config --filter=woocommerce
|
2022-05-17 01:47:17 +00:00
|
|
|
- name: Run analyzer
|
|
|
|
id: run
|
2022-07-14 03:39:38 +00:00
|
|
|
run: ./tools/code-analyzer/bin/dev analyzer "$GITHUB_HEAD_REF"
|
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:
|
|
|
|
github-token: ${{ secrets.WC_BOT_TRIAGE_TOKEN }}
|
|
|
|
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:
|
|
|
|
github-token: ${{ secrets.WC_BOT_TRIAGE_TOKEN }}
|
|
|
|
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-06-08 21:25:49 +00:00
|
|
|
github-token: ${{ secrets.WC_BOT_TRIAGE_TOKEN }}
|
|
|
|
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:
|
|
|
|
github-token: ${{ secrets.WC_BOT_TRIAGE_TOKEN }}
|
|
|
|
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:
|
|
|
|
github-token: ${{ secrets.WC_BOT_TRIAGE_TOKEN }}
|
|
|
|
script: |
|
|
|
|
github.rest.issues.removeLabel({
|
|
|
|
issue_number: context.issue.number,
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
name: ['release: highlight']
|
|
|
|
})
|