-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update and rename LeetCode.yml to IssueCloseAction.yml
- Loading branch information
Showing
2 changed files
with
74 additions
and
73 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: 이슈 닫힘 시 라벨별로 파일 생성 | ||
|
||
on: | ||
issues: | ||
types: [closed] | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
create_files_by_label: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: 레포지토리 체크아웃 | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # 전체 커밋 기록을 가져옵니다. | ||
|
||
- name: 이슈 정보 가져오기 | ||
id: issue_data | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const issue = context.payload.issue; | ||
core.setOutput('title', issue.title || 'untitled'); | ||
core.setOutput('body', issue.body || ''); | ||
core.setOutput('number', issue.number || ''); | ||
const labels = issue.labels.map(label => label.name); | ||
core.setOutput('labels', labels.join(',')); | ||
- name: 라벨이 있는지 확인 | ||
if: ${{ steps.issue_data.outputs.labels == '' }} | ||
run: | | ||
echo "이슈에 라벨이 없습니다. 작업을 종료합니다." | ||
exit 0 | ||
- name: 이슈 본문에서 코드 추출 | ||
id: extract_code | ||
run: | | ||
echo '이슈 본문에서 코드를 추출합니다...' | ||
echo "${{ steps.issue_data.outputs.body }}" > issue_body.txt | ||
code=$(grep -zoP '```(?:cpp)?\s*\n([\s\S]*?)\n```' issue_body.txt | sed -e 's/```cpp//' -e 's/```//' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') | ||
if [ -z "$code" ]; then | ||
echo "코드 블록을 찾을 수 없습니다. 작업을 종료합니다." | ||
exit 1 | ||
fi | ||
echo "$code" > code.cpp | ||
- name: 라벨별로 파일 생성 | ||
run: | | ||
labels="${{ steps.issue_data.outputs.labels }}" | ||
IFS=',' read -ra LABEL_ARRAY <<< "$labels" | ||
title="${{ steps.issue_data.outputs.title }}" | ||
sanitized_title=$(echo "$title" | tr '[:upper:]' '[:lower:]' | tr ' ' '_' | tr -cd '[:alnum:]_.-') | ||
for label in "${LABEL_ARRAY[@]}"; do | ||
sanitized_label=$(echo "$label" | tr '[:upper:]' '[:lower:]' | tr ' ' '_' | tr -cd '[:alnum:]_.-') | ||
folder="$sanitized_label" | ||
mkdir -p "$folder" | ||
cp code.cpp "$folder/$sanitized_title.cpp" | ||
echo "파일 생성: $folder/$sanitized_title.cpp" | ||
done | ||
- name: 변경 사항 커밋 및 푸시 | ||
uses: EndBug/add-and-commit@v9 | ||
with: | ||
message: "이슈 #${{ steps.issue_data.outputs.number }}에서 솔루션 추가" | ||
add: "*/*.cpp" | ||
author_name: GitHub Action | ||
author_email: [email protected] | ||
committer_name: GitHub Action | ||
committer_email: [email protected] | ||
pull_strategy: NO_REBASE # 푸시 전에 git pull을 수행합니다. | ||
token: ${{ secrets.GITHUB_TOKEN }} |
This file was deleted.
Oops, something went wrong.