mirror of
https://github.com/sunrin-ana/2025-SSF.git
synced 2026-03-09 18:40:02 +00:00
2025 SSF Public
This commit is contained in:
commit
76a02076c9
192 changed files with 5016 additions and 0 deletions
68
.github/workflows/black-check.yml
vendored
Normal file
68
.github/workflows/black-check.yml
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
name: Black Formatter Check
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
black-check:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Get commit messages
|
||||
id: commits
|
||||
run: |
|
||||
messages=$(gh pr view ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --json commits --jq '.commits[].message')
|
||||
if echo "$messages" | grep -q "chore: format code with black"; then
|
||||
echo "skip=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "skip=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
- name: Set up Python 3.x
|
||||
if: steps.commits.outputs.skip == 'false'
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
- name: Install black
|
||||
if: steps.commits.outputs.skip == 'false'
|
||||
run: pip install black
|
||||
|
||||
- name: Run black --check
|
||||
if: steps.commits.outputs.skip == 'false'
|
||||
id: black-check
|
||||
run: |
|
||||
black . --check
|
||||
continue-on-error: true
|
||||
|
||||
- name: Comment on PR (success)
|
||||
if: steps.commits.outputs.skip == 'false' && steps.black-check.outcome == 'success'
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
github-token: ${{ secrets.GH_TOKEN }}
|
||||
script: |
|
||||
github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
body: "> [!NOTE]\n> 🎉 Black 포매팅 검사가 성공적으로 완료되었어요.\n`/review`로 리뷰를 요청하실 수 있어요."
|
||||
})
|
||||
|
||||
- name: Comment on PR (failure)
|
||||
if: steps.commits.outputs.skip == 'false' && steps.black-check.outcome == 'failure'
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
github-token: ${{ secrets.GH_TOKEN }}
|
||||
script: |
|
||||
github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
body: "> [!WARNING]\n> 😢 코드 포매팅이 필요해요.\n`black .` 명령어로 코드를 포매팅하거나 `/format` 명령어를 사용해 주세요."
|
||||
})
|
||||
118
.github/workflows/comment-command.yml
vendored
Normal file
118
.github/workflows/comment-command.yml
vendored
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
name: PR Comment Commands
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
format:
|
||||
if: >
|
||||
startsWith(github.event.comment.body, '/format') &&
|
||||
github.event.issue.pull_request != null &&
|
||||
!contains(github.event.comment.body, '[!NOTE]')
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Checkout PR branch
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: refs/pull/${{ github.event.issue.number }}/head
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
- name: Set up Python 3.x
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
- name: Install black
|
||||
run: pip install black
|
||||
|
||||
- name: Run black
|
||||
run: black .
|
||||
|
||||
- name: Get PR branch name
|
||||
id: get_pr_branch
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
github-token: ${{ secrets.GH_TOKEN }}
|
||||
script: |
|
||||
const pr = await github.rest.pulls.get({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: context.issue.number
|
||||
});
|
||||
core.setOutput('branch', pr.data.head.ref);
|
||||
|
||||
- name: Commit & Push if changed
|
||||
env:
|
||||
PR_BRANCH: ${{ steps.get_pr_branch.outputs.branch }}
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
git add .
|
||||
git commit -m "chore: format code with black"
|
||||
git push origin HEAD:${PR_BRANCH}
|
||||
else
|
||||
echo "No changes to commit."
|
||||
fi
|
||||
|
||||
- name: Comment on PR
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
github-token: ${{ secrets.GH_TOKEN }}
|
||||
script: |
|
||||
github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
body: "> [!NOTE]\n> 코드 포매팅이 완료되었어요."
|
||||
})
|
||||
|
||||
review:
|
||||
if: >
|
||||
startsWith(github.event.comment.body, '/review') &&
|
||||
github.event.issue.pull_request != null &&
|
||||
!contains(github.event.comment.body, '[!NOTE]')
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- name: Label PR as "review required"
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
github-token: ${{ secrets.GH_TOKEN }}
|
||||
script: |
|
||||
github.rest.issues.addLabels({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
labels: ["status: review required"]
|
||||
})
|
||||
- name: Request reviewers
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
github-token: ${{ secrets.GH_TOKEN }}
|
||||
script: |
|
||||
const pr = await github.rest.pulls.get({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: context.issue.number
|
||||
});
|
||||
const submitter = pr.data.head.user.login;
|
||||
const reviewers = ["norhu1130", "janghanul090801"].filter(r => r !== submitter);
|
||||
if (reviewers.length > 0) {
|
||||
await github.rest.pulls.requestReviewers({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: context.issue.number,
|
||||
reviewers
|
||||
});
|
||||
}
|
||||
40
.github/workflows/issue_or_pr.yml.disabled
vendored
Normal file
40
.github/workflows/issue_or_pr.yml.disabled
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
name: Issue or PR Label
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened]
|
||||
issues:
|
||||
types: [opened]
|
||||
|
||||
jobs:
|
||||
add-label:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Check if issue or PR is opened
|
||||
id: check
|
||||
run: |
|
||||
if [[ "${{ github.event_name }}" == "issues" ]]; then
|
||||
echo "type=issue" >> $GITHUB_OUTPUT
|
||||
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
||||
echo "type=pull_request" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "type=unknown" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Add label to issue or PR
|
||||
if: steps.check.outputs.type == 'issue' || steps.check.outputs.type == 'pull_request'
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
github-token: ${{ secrets.GH_TOKEN }}
|
||||
script: |
|
||||
const label = steps.check.outputs.type === 'issue' ? 'type: issue' : 'type: pull request';
|
||||
await github.rest.issues.addLabels({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
labels: [label]
|
||||
});
|
||||
55
.github/workflows/pr-merge-status.yml
vendored
Normal file
55
.github/workflows/pr-merge-status.yml
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
name: PR Status - When Merged
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [closed]
|
||||
|
||||
jobs:
|
||||
handle-merge:
|
||||
# PR이 closed 되었을 때, merged 여부를 검사하여 merged=true인 경우에만 실행
|
||||
if: github.event.pull_request.merged == true
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Update status to done
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
github-token: ${{ secrets.GH_TOKEN }}
|
||||
script: |
|
||||
const prNumber = context.payload.pull_request.number;
|
||||
|
||||
const labelsToRemove = [
|
||||
"status: in progress",
|
||||
"status: review required",
|
||||
"status: change required",
|
||||
"status: waiting merge"
|
||||
];
|
||||
|
||||
const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: prNumber
|
||||
});
|
||||
|
||||
for (const labelName of labelsToRemove) {
|
||||
if (currentLabels.some(l => l.name === labelName)) {
|
||||
await github.rest.issues.removeLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: prNumber,
|
||||
name: labelName
|
||||
}).catch(err => {
|
||||
if (err.status !== 404) throw err;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 병합이 완료된 PR에 "status: done" 라벨을 부착
|
||||
await github.rest.issues.addLabels({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: prNumber,
|
||||
labels: ["status: done"]
|
||||
});
|
||||
66
.github/workflows/pr-review-status.yml
vendored
Normal file
66
.github/workflows/pr-review-status.yml
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
name: PR Status - Review Outcome
|
||||
|
||||
on:
|
||||
pull_request_review:
|
||||
types: [submitted]
|
||||
|
||||
jobs:
|
||||
handle-review-outcome:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Handle review outcomes
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
github-token: ${{ secrets.GH_TOKEN }}
|
||||
script: |
|
||||
const prNumber = context.payload.pull_request.number;
|
||||
|
||||
const labelInProgress = "status: in progress";
|
||||
const labelReviewReq = "status: review required";
|
||||
const labelChangeReq = "status: change required";
|
||||
const labelWaitingMerge = "status: waiting merge";
|
||||
|
||||
const labelsToRemove = [
|
||||
labelInProgress,
|
||||
labelReviewReq,
|
||||
labelChangeReq,
|
||||
labelWaitingMerge
|
||||
];
|
||||
|
||||
const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: prNumber
|
||||
});
|
||||
|
||||
for (const labelName of labelsToRemove) {
|
||||
if (currentLabels.some(l => l.name === labelName)) {
|
||||
await github.rest.issues.removeLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: prNumber,
|
||||
name: labelName
|
||||
}).catch(err => {
|
||||
if (err.status !== 404) throw err;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (context.payload.review.state === "approved") {
|
||||
await github.rest.issues.addLabels({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: prNumber,
|
||||
labels: [labelWaitingMerge]
|
||||
});
|
||||
} else if (context.payload.review.state === "changes_requested") {
|
||||
await github.rest.issues.addLabels({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: prNumber,
|
||||
labels: [labelChangeReq]
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue