Skip to content

Publish achievements #728

Publish achievements

Publish achievements #728

Workflow file for this run

name: Publish achievements
on:
schedule:
- cron: '10 17 * * *'
push:
branches: [ master ]
paths:
- 'cafecoder/**'
- 'yukicoder/**'
- 'atcoder/**'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# TODO remaining.py doesn't need secrets. We can place name and password in separate files and do away with this trick.
- name: Use dummy config file (CafeCoder)
run: |
echo 'name: kobae964' >>cafecoder/cafecoder_config
echo 'password: dummy-password' >>cafecoder/cafecoder_config
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint -r cafecoder/requirements.txt
- name: Generate JSON file (CafeCoder)
run: |
./cafecoder/remaining.py
./cafecoder/make_summary.py
if: false # Cafecoder's API server is down
- name: Generate JSON file (yukicoder)
run: |
./yukicoder/remaining.py koba-e964 >yukicoder/result.txt
EMIT_MD=1 ./yukicoder/remaining.py koba-e964 >yukicoder/result.md
- name: Generate files (AtCoder)
run: |
go build -o atcoder/remaining atcoder/remaining.go
atcoder/remaining >atcoder/result.txt
atcoder/remaining md >atcoder/result.md
- name: Checkout contest-achievements repo
uses: actions/checkout@v4
with:
repository: koba-e964/contest-achievements
ref: master
path: 'contest-achievements'
ssh-key: "${{ secrets.CONTEST_ACHIEVEMENT_PRIVATE_KEY }}"
- name: Place JSON and git push
working-directory: contest-achievements
run: |
mkdir -p cafecoder
# If the job for CafeCoder is not run, there are no generated files.
# So we ignore errors if these files are not present.
cp ../cafecoder/statuses.json ../cafecoder/summary.md cafecoder/ || true
mkdir -p yukicoder
# If the job for yukicoder is not run, there are no generated files.
# So we ignore errors if these files are not present.
cp ../yukicoder/result.md ../yukicoder/result.txt yukicoder/ || true
mkdir -p atcoder
# If the job for atcoder is not run, there are no generated files.
# So we ignore errors if these files are not present.
cp ../atcoder/result.txt ../atcoder/result.md atcoder/ || true
# https://zenn.dev/lollipop_onl/articles/eoz-gha-push-diffs
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add cafecoder/
git add yukicoder/
git add atcoder/
git commit -m 'Update achievements' || true
git push