-
Notifications
You must be signed in to change notification settings - Fork 3
88 lines (78 loc) · 3.28 KB
/
process-issue.yml
File metadata and controls
88 lines (78 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Process New Entry Issue
on:
issues:
types: [opened, edited]
permissions:
contents: write
pull-requests: write
issues: write
jobs:
process:
if: |
contains(github.event.issue.labels.*.name, 'add-model') ||
contains(github.event.issue.labels.*.name, 'add-dataset') ||
contains(github.event.issue.labels.*.name, 'add-simulator')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- name: Install dependencies
run: pip install -r requirements.txt
- name: Determine entry type from label
id: type
run: |
LABELS='${{ toJson(github.event.issue.labels.*.name) }}'
if echo "$LABELS" | grep -q "add-model"; then
echo "issue_type=model" >> $GITHUB_OUTPUT
elif echo "$LABELS" | grep -q "add-dataset"; then
echo "issue_type=dataset" >> $GITHUB_OUTPUT
else
echo "issue_type=tool" >> $GITHUB_OUTPUT
fi
- name: Parse issue and append entry
env:
ISSUE_BODY: ${{ github.event.issue.body }}
ISSUE_TYPE: ${{ steps.type.outputs.issue_type }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_AUTHOR: ${{ github.event.issue.user.login }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: python scripts/process_issue.py
- name: Regenerate site data
run: python scripts/generate_site.py
- name: Create branch and pull request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_AUTHOR: ${{ github.event.issue.user.login }}
run: |
BRANCH="add-entry/issue-${ISSUE_NUMBER}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "$BRANCH"
git add data/ docs/data.json docs/index.html README.md
git commit -m "feat: add entry from issue #${ISSUE_NUMBER}"
git push --force origin "$BRANCH"
PR_BODY=$(printf 'Resolves #%s\n\nAuto-generated from issue by @%s.\n\n**Please review the entry before merging.**' "${ISSUE_NUMBER}" "${ISSUE_AUTHOR}")
EXISTING_PR=$(gh pr list --head "$BRANCH" --json number --jq '.[0].number // empty')
if [ -z "$EXISTING_PR" ]; then
gh pr create \
--title "Add entry: ${ISSUE_TITLE}" \
--body "$PR_BODY" \
--head "$BRANCH" \
--base main
else
echo "PR #${EXISTING_PR} already exists for this branch — skipping creation"
fi
- name: Comment on issue
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
COMMENT=$(printf '✅ 감사합니다! PR이 자동으로 생성되었습니다. 관리자 검토 후 머지됩니다.\n\nThanks! A PR has been automatically created from this issue and is pending admin review.')
gh issue comment "${ISSUE_NUMBER}" --body "$COMMENT"