diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..834fde9 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,60 @@ +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: 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 + 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, '▲ 合并') + 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":["◈ 修正"]}'