Skip to content

Instantly share code, notes, and snippets.

@ryo-n
Last active December 29, 2023 12:04
Show Gist options
  • Save ryo-n/1f32e79eedd359b8bb1ac0320a6332bf to your computer and use it in GitHub Desktop.
Save ryo-n/1f32e79eedd359b8bb1ac0320a6332bf to your computer and use it in GitHub Desktop.
その日ACした問題一覧をdiscordに通知するaction
name: discord message
on:
workflow_dispatch:
schedule:
- cron: '15 21 * * *'
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: get solved problems from atcoder problemss a pi
continue-on-error: true
run: |
user=YOUR_ATCODER_ACCOUNT
(( a_day_ago_epoch=$(date +%s)-86400 )) || true
curl --compressed "https://kenkoooo.com/atcoder/atcoder-api/v3/user/submissions?user=${user}&from_second=${a_day_ago_epoch}" > result
result_num=$(jq '. | length' < result)
if [ "${result_num}" -eq 0 ]; then
exit 1
fi
jq -r '.[] | select(.result == "AC") | .result = .problem_id + " https://atcoder.jp/contests/" + .contest_id + "/submissions/" + (.id|tostring) + " " + .language | .result' < result > result2
echo "RESULT<<EOF" >> "$GITHUB_ENV"
echo "$(cat result2)" >> "$GITHUB_ENV"
echo "EOF" >> "$GITHUB_ENV"
- name: send custom message with args
if: success()
uses: appleboy/discord-action@master
with:
webhook_id: ${{ secrets.WEBHOOK_ID }}
webhook_token: ${{ secrets.WEBHOOK_TOKEN }}
args: "${{ env.RESULT }}"
@ryo-n
Copy link
Author

ryo-n commented Dec 28, 2023

YOUR_ATCODER_USERNAME を変更してご利用ください。
cron時刻は6:15JSTにしていますが、適切な時間にしてください

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment