Skip to content

Commit

Permalink
chore(other): 修改workflow触发机制 #836
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhw8 committed Aug 21, 2023
1 parent cd24149 commit 25b47e1
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/label_pr_merged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
name: Add "for test" Label

on:
pull_request:
pull_request_target:
types:
- closed

# 注意, fork 的仓库无法使用 GITHUB_TOKEN 权限,需要单独配置 github-token
permissions:
pull-requests: read
issues: write
Expand All @@ -20,13 +19,10 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
token: ${{ secrets.WORKFLOW_ACTION_TOKEN }}
- name: Get PR commits messages
id: pr-commits
uses: actions/github-script@v6
with:
github-token: ${{ secrets.WORKFLOW_ACTION_TOKEN }}
script: |
const { data: commits } = await github.rest.pulls.listCommits({
owner: context.repo.owner,
Expand All @@ -42,7 +38,6 @@ jobs:
- name: Add label to issues
uses: actions/github-script@v6
with:
github-token: ${{ secrets.WORKFLOW_ACTION_TOKEN }}
script: |
for (const issue_id of ${{ steps.pr-commits.outputs.issue_id_list }}) {
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
Expand Down Expand Up @@ -74,15 +69,13 @@ jobs:
close_issue:
needs: add_label
runs-on: ubuntu-latest

strategy:
matrix:
issue_id: ${{ fromJSON(needs.add_label.outputs.issue_id_list) }}
steps:
- name: Close Issue ${{ matrix.issue_id }}
uses: peter-evans/close-issue@v3
with:
token: ${{ secrets.WORKFLOW_ACTION_TOKEN }}
issue-number: ${{ matrix.issue_id }}
comment: Auto close issue after pr merged \#${{ github.event.number }}

0 comments on commit 25b47e1

Please sign in to comment.