This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Issue Label Handler | |
on: | |
issues: | |
types: [labeled] | |
jobs: | |
handle-label: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up environment variables | |
env: | |
ISSUE_NUMBER: ${{ github.event.issue.number }} | |
REPO_OWNER: ${{ github.repository_owner }} | |
REPO_NAME: ${{ github.event.repository.name }} | |
LABEL_NAME: ${{ github.event.label.name }} | |
GITHUB_TOKEN: ${{ secrets.BOT }} | |
run: | | |
echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> $GITHUB_ENV | |
echo "REPO_OWNER=$REPO_OWNER" >> $GITHUB_ENV | |
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV | |
echo "LABEL_NAME=$LABEL_NAME" >> $GITHUB_ENV | |
echo "GITHUB_TOKEN=$GITHUB_TOKEN" >> $GITHUB_ENV | |
- name: Determine action based on label | |
id: set_action | |
run: | | |
if [[ "$LABEL_NAME" == "❌ 拒绝" || "$LABEL_NAME" == "😂 移交上游" || "$LABEL_NAME" == "❌ 忽略" || "$LABEL_NAME" == "❌ 第三方" || "$LABEL_NAME" == "❌ 暂无计划" ]]; then | |
echo "::set-output name=state::closed" | |
elif [[ "$LABEL_NAME" == "👌 完成" ]]; then | |
echo "::set-output name=state::closed" | |
elif [[ "$LABEL_NAME" == "❌ 重复" ]]; then | |
echo "::set-output name=state::closed" | |
else | |
echo "::set-output name=state::open" | |
fi | |
- name: Close issue if needed | |
if: steps.set_action.outputs.state == 'closed' | |
run: | | |
curl -X PATCH \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/issues/$ISSUE_NUMBER \ | |
-d "{\"state\": \"${{ steps.set_action.outputs.state }}\"}" | |