Skip to content

Commit

Permalink
Create GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Deep-Dark-Forest authored Sep 7, 2024
1 parent b11e4cf commit f940504
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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":["◈ 修正"]}'

0 comments on commit f940504

Please sign in to comment.