Skip to content

ryan: week5 special #97

ryan: week5 special

ryan: week5 special #97

Workflow file for this run

name: Solution Upload Notifier
on:
push:
paths:
- "*/*/*.py"
- "*/*/*.js"
- "*/*/*.java"
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2 # fetch at least 2 commits
- name: Ensure previous commit exists
run: |
if ! git rev-parse HEAD~1 >/dev/null 2>&1; then
echo "No previous commit — skipping diff."
exit 0
fi
- name: Get newly added solution files
id: files
shell: bash
run: |
added=$(git diff --name-only --diff-filter=A HEAD~1 HEAD \
| grep -E ".+/.+/.+\.(py|js|java)$" || true)
echo "Detected files:"
echo "$added"
{
echo "added<<EOF"
echo "$added"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Exit if no new solutions
if: ${{ steps.files.outputs.added == '' }}
run: |
echo "No new solution files added."
exit 0
- name: Process each new solution file
env:
API_URL: ${{ secrets.NOTIFIER_API_URL }}
API_SECRET: ${{ secrets.NOTIFIER_API_SECRET }}
CHANNEL_ID: ${{ secrets.NOTIFIER_CHANNEL_ID }}
ADDED_FILES: ${{ steps.files.outputs.added }}
shell: bash
run: |
while IFS= read -r file; do
[ -z "$file" ] && continue
echo "Processing $file"
username=$(echo "$file" | cut -d'/' -f1)
week=$(echo "$file" | cut -d'/' -f2)
filename=$(echo "$file" | cut -d'/' -f3)
difficulty="${filename%.*}"
message="사용자 ${username}님께서 ${week}의 문제 ${difficulty}에 대한 솔루션을 업로드하셨습니다."
echo "Sending: $message"
curl -s -X POST "$API_URL" \
-H "Content-Type: application/json" \
-H "X-API-Key: $API_SECRET" \
-d "{
\"channelId\": \"$CHANNEL_ID\",
\"message\": \"$message\",
\"type\": \"channel\"
}"
done <<< "$ADDED_FILES"