Fetch from usaco-problems #22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Fetch from usaco-problems | |
on: workflow_dispatch | |
jobs: | |
update_problems: | |
name: Update problems | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout usaco-guide | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Use Node.js 20.x | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 20.x | |
- name: Checkout usaco-problems | |
uses: actions/checkout@v2 | |
with: | |
repository: ${{ github.repository_owner }}/usaco-problems | |
path: usaco-problems | |
- name: Generate a token | |
id: generate_token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ secrets.APP_ID }} | |
private-key: ${{ secrets.APP_PRIVATE_KEY }} | |
owner: ${{ github.repository_owner }} | |
- name: Checkout auto | |
run: | | |
export pr_number=$(gh pr list --author 'usaco-autofetch[bot]' --json number --jq '.[0].number') | |
echo "pr_number: $pr_number" | |
if [ -z "$pr_number" ] | |
then | |
git checkout -B auto | |
git push -f origin auto | |
else | |
git checkout auto | |
fi | |
pip install pre-commit | |
pre-commit install | |
env: | |
GH_TOKEN: ${{ steps.generate_token.outputs.token }} | |
- name: Update contest to points | |
run: | | |
pip install -r src/components/markdown/ProblemsList/DivisionList/scripts/requirements.txt | |
python src/components/markdown/ProblemsList/DivisionList/scripts/update.py -s $(date +%y) -e $(date +%y) | |
- name: Build list of problem ids | |
run: | | |
yarn | |
yarn build | |
echo 'ids.log tail:' | |
cat -b ids.log | tail -n 10 | |
- name: Add new problems | |
run: | | |
npx ts-node --skipProject usaco-problems/add_problems | |
git add . | |
git config --global user.name usaco-autofetch[bot] | |
git config --global user.email usaco-autofetch[bot]@users.noreply.github.com | |
if git commit -m 'problem auto-updates' | |
then | |
git push origin auto | |
if [ -z "$pr_number" ] | |
then | |
gh pr create --title 'Problem auto-updates' -F usaco-problems/out/report.txt | |
else | |
gh pr edit $pr_number -F usaco-problems/out/report.txt | |
fi | |
else | |
echo 'Problems up to date!' | |
fi | |
env: | |
GH_TOKEN: ${{ steps.generate_token.outputs.token }} |