From 39591c1f851c4d8591f9bba48aef0c6b41374d90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B7=B1=E9=BB=91=E6=A3=AE=E6=9E=97?= <131975043+Deep-Dark-Forest@users.noreply.github.com> Date: Sat, 7 Sep 2024 18:41:09 +0800 Subject: [PATCH 1/4] Create main.yml --- .github/workflows/main.yml | 65 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..b14b09b --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,65 @@ +name: auto-PR + +on: + pull_request: + types: [opened, labeled, unlabeled, review_requested, review_request_removed, review_submitted] + +jobs: + pr_workflow: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Request review from WForst-Breeze on PR creation + if: github.event.action == 'opened' + run: | + curl -X POST \ + -H "Authorization: token ${{ secrets.SHEEP }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers \ + -d '{"reviewers":["WForst-Breeze"]}' + + - name: Add "▲ 合并" label on PR merge + if: github.event.action == 'closed' && github.event.pull_request.merged == true + run: | + curl -X POST \ + -H "Authorization: token ${{ secrets.SHEEP }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \ + -d '{"labels":["▲ 合并"]}' + + - name: Auto-merge PR with "▲ 合并" label + if: contains(github.event.pull_request.labels.*.name, '▲ 合并') + run: | + curl -X PUT \ + -H "Authorization: token ${{ secrets.SHEEP }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/merge + + - name: Add "⇵ 通过" label on approval by WForst-Breeze + if: github.event.action == 'submitted' && github.event.review.state == 'approved' && github.event.review.user.login == 'WForst-Breeze' + run: | + curl -X POST \ + -H "Authorization: token ${{ secrets.SHEEP }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \ + -d '{"labels":["⇵ 通过"]}' + + - name: Close PR with specific labels + if: contains(github.event.pull_request.labels.*.name, '× 重新编写') || contains(github.event.pull_request.labels.*.name, '× 无效') || contains(github.event.pull_request.labels.*.name, '× 拒绝') + run: | + curl -X PATCH \ + -H "Authorization: token ${{ secrets.SHEEP }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }} \ + -d '{"state":"closed"}' + + - name: Add "◈ 修正" label on request changes + if: github.event.action == 'submitted' && github.event.review.state == 'changes_requested' + run: | + curl -X POST \ + -H "Authorization: token ${{ secrets.SHEEP }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \ + -d '{"labels":["◈ 修正"]}' From b87224ec9a2375ff4eefaf153e7dce28f576db9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B7=B1=E9=BB=91=E6=A3=AE=E6=9E=97?= <131975043+Deep-Dark-Forest@users.noreply.github.com> Date: Sat, 7 Sep 2024 19:21:47 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20main.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b14b09b..7cd8f73 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,13 +21,12 @@ jobs: -d '{"reviewers":["WForst-Breeze"]}' - name: Add "▲ 合并" label on PR merge - if: github.event.action == 'closed' && github.event.pull_request.merged == true - run: | - curl -X POST \ - -H "Authorization: token ${{ secrets.SHEEP }}" \ - -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \ - -d '{"labels":["▲ 合并"]}' + if: github.event.action == 'closed' && github.event.pull_request.merged == true + - name: Add merge label + uses: actions-ecosystem/action-add-labels@v1 + with: + github_token: ${{ secrets.SHEEP }} + labels: '▲ 合并' - name: Auto-merge PR with "▲ 合并" label if: contains(github.event.pull_request.labels.*.name, '▲ 合并') From 135472c2c280a42d1d1e25f934cbb290b700ac5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B7=B1=E9=BB=91=E6=A3=AE=E6=9E=97?= <131975043+Deep-Dark-Forest@users.noreply.github.com> Date: Sat, 7 Sep 2024 19:25:19 +0800 Subject: [PATCH 3/4] Update main.yml --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7cd8f73..de0e0d7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,8 +21,7 @@ jobs: -d '{"reviewers":["WForst-Breeze"]}' - name: Add "▲ 合并" label on PR merge - if: github.event.action == 'closed' && github.event.pull_request.merged == true - - name: Add merge label + if: github.event.action == 'closed' && github.event.pull_request.merged == true uses: actions-ecosystem/action-add-labels@v1 with: github_token: ${{ secrets.SHEEP }} From f5643580dedd5241ee10148657ef0e56f7022897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B7=B1=E9=BB=91=E6=A3=AE=E6=9E=97?= <131975043+Deep-Dark-Forest@users.noreply.github.com> Date: Sat, 7 Sep 2024 19:28:44 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20main.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index de0e0d7..834fde9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,9 +8,6 @@ jobs: pr_workflow: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v2 - - name: Request review from WForst-Breeze on PR creation if: github.event.action == 'opened' run: |