Build #306
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: Build | |
| on: | |
| schedule: | |
| - cron: '0 0-9 * * 1-5' | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.PAT }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Update metadata.json | |
| run: | | |
| URL=$(curl -G 'https://api.thecatapi.com/v1/images/search?size=med&mime_types=jpg&order=RANDOM' | jq -r '.[0].url') | |
| echo "{\"imageUrl\":\"$URL\",\"timestamp\":$(date +%s)}" > public/metadata.json | |
| - name: Build | |
| run: npm run build | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name 'gh-actions' | |
| git config --global user.email '[email protected]' | |
| - name: Commit and push if changed | |
| run: | | |
| git add -A | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| else | |
| git commit -m "build" | |
| git push | |
| fi |