Skip to content

<添加比赛>

<添加比赛> #115

Workflow file for this run

name: Save Issue as JSON
on:
issues:
types: [opened]
permissions:
contents: write
issues: write
pull-requests: write
jobs:
save-and-create-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Save Issue to JSON
run: |
line=$(cat ${GITHUB_EVENT_PATH} | jq -r '.issue.body' | head -n 1)
if [ "$line" != "### 赛事名称" ] ; then
exit 0
fi
jq -r '.issue.body' "${GITHUB_EVENT_PATH}" > temp
python issue2Event.py
echo "EVENTNAME=$(<temp_name)" >> $GITHUB_ENV
rm temp temp_name temp_json
- name: Check for changes
id: check_changes
run: |
git add .
if [ -n "$(git status --porcelain)" ]; then
echo "CHANGES=true" >> $GITHUB_ENV
fi
- name: Sync with Remote Main Branch
if: env.CHANGES == 'true'
run: |
git fetch origin main
git checkout main
git pull origin main
git checkout -b review-pending-${{ env.EVENTNAME }}
- name: Commit changes
if: env.CHANGES == 'true'
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git add .
git commit -m "[bot]添加赛事待审核"
- name: Push changes
if: env.CHANGES == 'true'
run: |
git push --set-upstream origin review-pending-${{ env.EVENTNAME }}
- name: Create Pull Request
if: env.CHANGES == 'true'
uses: repo-sync/pull-request@v2
with:
source_branch: "review-pending-${{ env.EVENTNAME }}"
destination_branch: "main"
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_title: "[bot] 添加的赛事 ${{ env.EVENTNAME }} 待审核"
pr_body: "请审查提交的赛事信息:\n\n${{ github.event.issue.body }}"
pr_label: "赛事审核"
- name: Close Issue with Comment
if: env.CHANGES == 'true'
uses: actions-cool/issues-helper@v3
with:
actions: 'close-issues'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
close-reason: completed
body: |
比赛已经被提交审核,issue将关闭,审核结果请关注Pr,若对此存有疑问,可评论回复询问。