-
Notifications
You must be signed in to change notification settings - Fork 8
69 lines (59 loc) · 2.24 KB
/
update-poetry.yml
File metadata and controls
69 lines (59 loc) · 2.24 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
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
- 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: 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;
}
// 코멘트를 포함하는지 확인
if (!commentBody.includes("@bot update 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 }}"
git push origin main