Skip to content

Commit

Permalink
๐Ÿšš Setting(.github/workflows): github action์„ ํ†ตํ•ด ์—ด๋ฆฐ PR์— ๋Œ€ํ•ด์„œ ์ž๋™์œผ๋กœ ์•Œ๋ฆผ์„ ๋ณดโ€ฆ
Browse files Browse the repository at this point in the history
โ€ฆ๋‚ด์ฃผ๊ฒŒ๋” ์„ค์ •

ISSUES CLOSED: #80
  • Loading branch information
SeoGeonhyuk committed Nov 19, 2024
1 parent 60d5a1d commit 00a3c86
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/check-open-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Check Open PRs and Notify Slack

on:
schedule:
# ๋งค 1์‹œ๊ฐ„๋งˆ๋‹ค ์‹คํ–‰
- cron: '0 * * * *'

workflow_dispatch: # ์ˆ˜๋™ ์‹คํ–‰์„ ์œ„ํ•œ ํŠธ๋ฆฌ๊ฑฐ
inputs:
force_notify:
description: "Force Slack notification"

jobs:
notify_open_prs:
runs-on: ubuntu-latest

steps:
# 1. GitHub ๋ฆฌํฌ์ง€ํ† ๋ฆฌ ์ฒดํฌ์•„์›ƒ
- name: Checkout repository
uses: actions/checkout@v3

# 2. PR ๋ฐ์ดํ„ฐ ์ˆ˜์ง‘
- name: Fetch Open PRs with Reviewers
id: fetch_prs
run: |
# ๋ชจ๋“  ์—ด๋ฆฐ PR ๊ฐ€์ ธ์˜ค๊ธฐ
prs=$(gh pr list --json number,title,url,reviewRequests --jq '.[] | select(.reviewRequests | length > 0)')
echo "Found PRs: $prs"
# JSON ๋ฐ์ดํ„ฐ๋ฅผ Action output์œผ๋กœ ์ €์žฅ
echo "::set-output name=prs::$prs"
env:
GITHUB_TOKEN: ${{ secrets.G_TOKEN }} # GitHub ๊ธฐ๋ณธ ์ œ๊ณต ํ† ํฐ

# 3. Slack ์•Œ๋ฆผ ์ „์†ก
- name: Notify Slack
if: steps.fetch_prs.outputs.prs != '' # ์—ด๋ฆฐ PR์ด ์žˆ์„ ๋•Œ๋งŒ ์‹คํ–‰
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # Slack ์›นํ›… URL
run: |
echo "Preparing Slack notification..."
prs_json='${{ steps.fetch_prs.outputs.prs }}'
if [ -z "$prs_json" ]; then
echo "No PRs to notify about."
exit 0
fi
# Slack ๋ฉ”์‹œ์ง€ ์ž‘์„ฑ
message=":warning: *Open Pull Requests with Reviewers:*"
echo $prs_json | jq -c '.[]' | while read -r pr; do
title=$(echo $pr | jq -r '.title')
url=$(echo $pr | jq -r '.url')
reviewers=$(echo $pr | jq -r '.reviewRequests | map(.login) | join(", ")')
message+="\n- <$url|$title> (Reviewers: $reviewers)"
done
# Slack ๋ฉ”์‹œ์ง€ ์ „์†ก
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"$message\"}" $SLACK_WEBHOOK_URL

0 comments on commit 00a3c86

Please sign in to comment.