autofetch #100
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: autofetch | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 0 * 12,1,2,3 2,3,4' | |
push: | |
paths: | |
- '.github/workflows/autofetch.yml' | |
- 'usaco_util.ts' | |
- 'add_problems.ts' | |
- 'update_ide.ts' | |
- 'run.sh' | |
- 'push.sh' | |
jobs: | |
scrape_usaco: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Install dependencies | |
run: npm i | |
- name: Add problems | |
run: npx ts-node --skipProject usaco_util.ts | |
- name: Push changes | |
run: source push.sh | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Update usacoProblems for IDE | |
run: npx ts-node update_ide | |
env: | |
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }} | |
- 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: Ping usaco-guide | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ steps.generate_token.outputs.token }} | |
script: | | |
github.rest.actions.createWorkflowDispatch({ | |
owner: '${{ github.repository_owner }}', | |
repo: 'usaco-guide', | |
workflow_id: 'update-usaco.yml', | |
ref: 'master', | |
}) | |