Skip to content
Closed
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
103 changes: 103 additions & 0 deletions .github/workflows/check-project-scheduled.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Project Week Check (Scheduled) 🔔

on:
schedule:
# 매일 오전 10시, 오후 6시 (KST 기준, UTC로는 1시, 9시)
- cron: "0 1,9 * * *"
pull_request:
types: [opened, reopened, synchronize, edited, labeled, unlabeled]
workflow_dispatch: # 수동 실행

jobs:
check-all-prs:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write # PR 댓글 작성 권한
pull-requests: write # PR 정보 읽기 권한

steps:
- name: Get all open PRs
id: get-prs
run: |
echo "📋 Open PR 목록 조회 중..."
prs=$(gh pr list \
--repo ${{ github.repository }} \
--state open \
--json number,labels \
--limit 100)

echo "prs=$prs" >> $GITHUB_OUTPUT
echo "Open PR 수: $(echo $prs | jq 'length')"
env:
GH_TOKEN: ${{ github.token }}

- name: Check Week settings for all PRs
run: |
prs='${{ steps.get-prs.outputs.prs }}'
WORKER_URL="https://dalestudy.daleseo.workers.dev"
repo_owner="${{ github.repository_owner }}"
repo_name="${{ github.event.repository.name }}"

echo "$prs" | jq -c '.[]' | while read -r pr; do
pr_number=$(echo $pr | jq -r '.number')
labels=$(echo $pr | jq -r '.labels[].name' | tr '\n' ',')

# maintenance 라벨이 있으면 스킵
if echo "$labels" | grep -q "maintenance"; then
echo "⏭️ PR #$pr_number: maintenance 라벨 - 스킵"
continue
fi

echo ""
echo "🔍 PR #$pr_number 검사 중..."

# GitHub App으로 Week 설정 확인
response=$(curl -s -X POST "$WORKER_URL" \
-H "Content-Type: application/json" \
-d "{\"pr_number\": $pr_number, \"repo_owner\": \"$repo_owner\", \"repo_name\": \"$repo_name\"}")

week=$(echo $response | jq -r '.week')
project_found=$(echo $response | jq -r '.project_found')

echo " Week: $week"
echo " Project found: $project_found"

# Week 설정이 없으면 댓글 작성
if [ "$week" = "null" ] || [ -z "$week" ]; then
echo " ⚠️ Week 설정 누락 - 댓글 작성 시도"

# 이미 봇이 댓글을 달았는지 확인 (에러 발생 시 무시)
existing_comment=$(gh pr view $pr_number \
--repo ${{ github.repository }} \
--json comments \
--jq '.comments[] | select(.author.login == "github-actions[bot]") | select(.body | contains("Week 설정이 누락")) | .id' \
2>/dev/null | head -n 1) || true

if [ -z "$existing_comment" ]; then
# 새 댓글 작성
if gh pr comment $pr_number \
--repo ${{ github.repository }} \
--body $'## ⚠️ Week 설정이 누락되었습니다\n\n프로젝트에서 Week를 설정해주세요!\n\n### 설정 방법\n1. PR 우측의 `Projects` 섹션에서 `리트코드 스터디` 옆 드롭다운(▼) 클릭\n2. 현재 주차를 선택해주세요 (예: `Week 14(current)` 또는 `Week 14`)\n\n📚 [자세한 가이드 보기](https://github.com/DaleStudy/leetcode-study/wiki/%EB%8B%B5%EC%95%88-%EC%A0%9C%EC%B6%9C-%EA%B0%80%EC%9D%B4%EB%93%9C#pr-%EC%9E%91%EC%84%B1%EB%B2%95)\n\n---\n🤖 이 댓글은 GitHub App을 통해 자동으로 작성되었습니다.' 2>/dev/null; then
echo " ✅ 댓글 작성 완료"
else
echo " ❌ 댓글 작성 실패 (권한 문제 가능성)"
fi
else
echo " ℹ️ 이미 알림 댓글이 있음 - 스킵"
fi
else
echo " ✅ Week 설정 정상: $week"
fi
done
env:
GH_TOKEN: ${{ github.token }}

- name: Summary
run: |
echo "## 🎯 Week 설정 체크 완료" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "모든 Open PR의 Week 설정을 확인했습니다." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- Week 설정이 없는 PR에 자동으로 댓글을 작성했습니다." >> $GITHUB_STEP_SUMMARY
echo "- 다음 체크: $(date -u -d '+1 hour' +'%Y-%m-%d %H:00 UTC')" >> $GITHUB_STEP_SUMMARY
116 changes: 116 additions & 0 deletions .github/workflows/check-project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Check Project Week 🗓️

on:
pull_request:
types: [opened, reopened, synchronize, edited, labeled, unlabeled]
workflow_dispatch: # 수동 실행
inputs:
pr_number:
description: 'PR 번호'
required: true
type: number
issue_comment: # PR 댓글로 재실행
types: [created]

jobs:
check-project:
runs-on: ubuntu-latest
# issue_comment 이벤트는 /check-week 명령어가 있을 때만 실행
if: |
github.event_name != 'issue_comment' ||
(github.event.issue.pull_request && contains(github.event.comment.body, '/check-week'))
permissions:
contents: read
pull-requests: read

steps:
# PR 번호 결정
- name: Determine PR number
id: pr-info
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
pr_number="${{ inputs.pr_number }}"
elif [ "${{ github.event_name }}" = "issue_comment" ]; then
pr_number="${{ github.event.issue.number }}"
else
pr_number="${{ github.event.pull_request.number }}"
fi
echo "pr_number=$pr_number" >> $GITHUB_OUTPUT
echo "🔍 PR 번호: $pr_number"
# PR 라벨 확인
- name: Get PR labels
id: pr-labels
run: |
pr_number="${{ steps.pr-info.outputs.pr_number }}"
repo="${{ github.repository }}"
echo "📋 PR 라벨 조회 중..."
labels_json=$(gh pr view $pr_number --repo $repo --json labels -q '.labels[].name')
echo "확인된 라벨: $labels_json"
if [ -n "$labels_json" ]; then
has_maintenance=$(echo $labels_json | grep -q 'maintenance' && echo 'true' || echo 'false')
echo "maintenance 라벨 포함 여부: $has_maintenance"
echo "has_maintenance=$has_maintenance" >> $GITHUB_OUTPUT
else
echo "maintenance 라벨이 없는 PR입니다. Week 설정을 검사합니다."
echo "has_maintenance=false" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ github.token }}

# Week 설정 확인 (Cloudflare Worker 호출)
- name: Check Week setting in project
if: ${{ steps.pr-labels.outputs.has_maintenance != 'true' }}
run: |
echo "🔍 Week 설정 검사 시작"
pr_number="${{ steps.pr-info.outputs.pr_number }}"
repo_owner="${{ github.repository_owner }}"
repo_name="${{ github.event.repository.name }}"
WORKER_URL="https://dalestudy.daleseo.workers.dev"
echo "📋 Cloudflare Worker를 통해 프로젝트 정보 조회 중..."
response=$(curl -s -X POST "$WORKER_URL" \
-H "Content-Type: application/json" \
-d "{\"pr_number\": $pr_number, \"repo_owner\": \"$repo_owner\", \"repo_name\": \"$repo_name\"}")
echo "응답: $response"
# 에러 체크
if echo "$response" | jq -e '.error' > /dev/null; then
error_msg=$(echo "$response" | jq -r '.error')
echo "⚠️ Worker 에러: $error_msg"
echo "## ❌ Week 설정 검증 실패" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "프로젝트 정보를 조회할 수 없습니다: $error_msg" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "📚 [답안 제출 가이드 참고](https://github.com/DaleStudy/leetcode-study/wiki/%EB%8B%B5%EC%95%88-%EC%A0%9C%EC%B6%9C-%EA%B0%80%EC%9D%B4%EB%93%9C#pr-%EC%9E%91%EC%84%B1%EB%B2%95)" >> $GITHUB_STEP_SUMMARY
exit 1
fi
# Week 값 추출
week_value=$(echo "$response" | jq -r '.week')
project_found=$(echo "$response" | jq -r '.project_found')
echo "추출된 Week 값: '$week_value'"
echo "프로젝트 발견 여부: $project_found"
if [ "$week_value" = "null" ] || [ -z "$week_value" ]; then
echo "## ❌ Week 설정 검증 실패" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "⚠️ **PR에 Week 설정이 누락되었습니다!**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 설정 방법" >> $GITHUB_STEP_SUMMARY
echo "1. PR 우측의 \`Projects\` 섹션에서 \`리트코드 스터디\` 옆 드롭다운(▼) 클릭" >> $GITHUB_STEP_SUMMARY
echo "2. 현재 주차를 선택해주세요 (예: \`Week 14(current)\` 또는 \`Week 14\`)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "📚 [자세한 가이드 보기](https://github.com/DaleStudy/leetcode-study/wiki/%EB%8B%B5%EC%95%88-%EC%A0%9C%EC%B6%9C-%EA%B0%80%EC%9D%B4%EB%93%9C#pr-%EC%9E%91%EC%84%B1%EB%B2%95)" >> $GITHUB_STEP_SUMMARY
exit 1
fi
echo "## ✅ Week 설정 검증 성공" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Week 설정: **$week_value**" >> $GITHUB_STEP_SUMMARY
echo "✅ Week 설정이 올바르게 되어 있습니다!"
19 changes: 19 additions & 0 deletions reverse-bits/DaleSeo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// TC: O(1)
// SC: O(1)
impl Solution {
pub fn reverse_bits(n: i32) -> i32 {
let mut result = 0u32;
let mut num = n as u32;

for i in 0..32 {
// Extract the least significant bit
let bit = num & 1;
// Place it in the reversed position
result |= bit << (31 - i);
// Shift num right to process the next bit
num >>= 1;
}

result as i32
}
}
Loading