89 lines
3.9 KiB
YAML
89 lines
3.9 KiB
YAML
|
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
|
||
|
pnpm install
|
||
|
- name: Run analyzer
|
||
|
id: run
|
||
|
run: ./tools/code-analyzer/bin/dev analyzer "$GITHUB_HEAD_REF" -o github
|
||
|
- name: Print results
|
||
|
id: results
|
||
|
run: echo "::set-output name=results::${{ steps.run.outputs.templates }}${{ steps.run.outputs.wphooks }}"
|
||
|
comment:
|
||
|
name: Add comment to hightlight changes
|
||
|
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 }}
|
||
|
comment-author: woocommercebot
|
||
|
- 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,
|
||
|
body: '## New hook or template changes in this PR${{ needs.analyze.outputs.results }}'
|
||
|
})
|
||
|
- 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,
|
||
|
body: '## New hook or template changes in this PR${{ needs.analyze.outputs.results }}'
|
||
|
})
|
||
|
- name: Delete comment
|
||
|
if: ${{ !needs.analyze.outputs.results && steps.find-comment.outputs.comment-id }}
|
||
|
uses: izhangzhihao/delete-comment@master
|
||
|
with:
|
||
|
github_token: ${{ secrets.WC_BOT_TRIAGE_TOKEN }}
|
||
|
delete_user_name: woocommercebot
|
||
|
issue_number: ${{ github.event.number }}
|
||
|
- 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']
|
||
|
})
|