-
Notifications
You must be signed in to change notification settings - Fork 1
78 lines (68 loc) · 2.63 KB
/
update-poetry.yml
File metadata and controls
78 lines (68 loc) · 2.63 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
name: Update Poetry Dependencies on Command
on:
issue_comment:
types: [created] # 새로운 댓글이 작성될 때 실행
jobs:
update-poetry:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Python and Poetry
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Reset Poetry Virtual Environment
run: |
poetry env remove python || true
poetry cache clear pypi --all
poetry config virtualenvs.in-project true
poetry install
- name: Extract Package Name if Comment is from BAEM1N
id: extract_package
uses: actions/github-script@v7
with:
script: |
const commentBody = context.payload.comment.body;
const commenter = context.payload.comment.user.login;
const issueBody = context.payload.issue.body;
// 관리자 확인
if (commenter !== "BAEM1N") {
console.log(`Unauthorized user: ${commenter}. Skipping package update.`);
return null;
}
// 코멘트가 "@bot add package"를 포함하는지 확인
if (!commentBody.includes("@bot add package")) {
console.log("Command not detected. Skipping...");
return null;
}
// "Package Name"에서 패키지 이름 추출
const packageNameMatch = issueBody.match(/Package Name\s*\n\s*(\S+)/);
if (packageNameMatch) {
return packageNameMatch[1].trim();
} else {
console.log("Package Name not found.");
return null;
}
- name: Add package to pyproject.toml
if: steps.extract_package.outputs.result != ''
run: |
PACKAGE_NAME="${{ steps.extract_package.outputs.result }}"
poetry add "$PACKAGE_NAME"
- name: Commit and push changes
if: steps.extract_package.outputs.result != ''
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add pyproject.toml poetry.lock
git commit -m "Added ${{ steps.extract_package.outputs.result }} via package request by BAEM1N"
git push origin main