Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions .github/workflows/d-day-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Update D-n Labels

on:
schedule:
- cron: '0 0 * * *' # UTC 00:00 = KST 09:00

permissions:
contents: read
pull-requests: write

jobs:
d-day-labeler:
runs-on: ubuntu-latest

steps:
# Step A: 업데이트 전 상태 스냅샷
- name: Snapshot BEFORE d-day update
id: before
uses: actions/github-script@v7
with:
script: |
const pulls = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: "open",
base: "dev"
});

const before = {};
for (const pr of pulls.data) {
const d = pr.labels.find(l => /^D-\d+$/.test(l.name));
if (d) before[pr.number] = d.name;
}

return before;

# Step B: D-n 라벨 업데이트
- name: Update D-n Labels
uses: naver/d-day-labeler@latest
with:
token: ${{ secrets.GITHUB_TOKEN }}

# Step C: 업데이트 후 상태 + diff 판단
- name: Detect D-2→D-1 / D-1→D-0
id: detect
uses: actions/github-script@v7
with:
script: |
const before = JSON.parse(`${{ steps.before.outputs.result }}`);

const pulls = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: "open",
base: "dev"
});

const notify = [];

for (const pr of pulls.data) {
const afterLabel = pr.labels.find(l => /^D-\d+$/.test(l.name));
if (!afterLabel) continue;

const after = afterLabel.name;
const prev = before[pr.number];

if (
(prev === "D-2" && after === "D-1") ||
(prev === "D-1" && after === "D-0")
) {
notify.push({
number: pr.number,
title: pr.title,
url: pr.html_url,
prefix: after === "D-0" ? "🚨 [D-0]" : "⏳ [D-1]"
});
}
}

return notify;

# Discord 알림
- name: Send Discord notification
if: ${{ steps.detect.outputs.result != '[]' }}
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_PR_REMINDER_WEBHOOK_URL }}
run: |
content=$(echo '${{ steps.detect.outputs.result }}' | jq -r '
.[] |
(.prefix + " PR #" + (.number|tostring) + ": " + .title) + "\n" + .url + "\n"
')

jq -n \
--arg title "⏰ 마감 임박 PR 알림" \
--arg body "$content" \
'{content: ($title + "\n\n" + $body)}' \
| curl -X POST \
-H "Content-Type: application/json" \
-d @- \
"$DISCORD_WEBHOOK_URL"
21 changes: 21 additions & 0 deletions .github/workflows/simple-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Simple Labeler

on:
pull_request:
types: [opened, ready_for_review]
branches:
- dev

permissions:
pull-requests: write

jobs:
simple-labeler:
runs-on: [ubuntu-latest]
steps:
- name: Label to PR
uses: naver/simple-labeler@latest
with:
token: ${{ secrets.GITHUB_TOKEN }}
labels: "D-4"
duplicate: "D-*"
Loading