Download New Content #227
This file contains hidden or 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: Download New Content | |
| on: | |
| schedule: | |
| - cron: 30 5 * * * | |
| workflow_dispatch: | |
| jobs: | |
| Download: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Restore content from cache | |
| uses: actions/cache/restore@v4 | |
| with: | |
| restore-keys: content- | |
| path: cache/ | |
| key: "_" | |
| - name: Download content if necessary | |
| id: download | |
| run: | | |
| npm run download; | |
| echo "updated=$(cat updated)" >> $GITHUB_OUTPUT; | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.PRIVILEGED_GITHUB_TOKEN }} | |
| - name: Print status of cache | |
| run: | | |
| mkdir -p cache; | |
| tree cache; | |
| - name: Get Date | |
| id: get-date | |
| run: | | |
| echo "date=$(/bin/date -u "+%Y%m%d%H%M%S")" >> $GITHUB_OUTPUT | |
| shell: bash | |
| - name: Save content to cache | |
| uses: actions/cache/save@v4 | |
| if: ${{ steps.download.outputs.updated != '0' }} | |
| with: | |
| path: cache/ | |
| key: content-${{ steps.get-date.outputs.date }} | |
| - name: Trigger another workflow | |
| if: ${{ steps.download.outputs.updated != '0' }} | |
| run: | | |
| gh api repos/${{ github.repository }}/dispatches -f event_type=content_changed; | |
| env: | |
| GH_TOKEN: ${{ github.token }} |