Deploy CheatSheetz #184
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: Deploy CheatSheetz | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths-ignore: | |
| - '.github/workflows/**' | |
| schedule: | |
| # Build twice daily at 6 AM and 6 PM UTC | |
| - cron: '0 6,18 * * *' | |
| workflow_dispatch: | |
| # Prevent workflow-triggered pushes from starting another build | |
| concurrency: | |
| group: deploy-cheatsheetz | |
| cancel-in-progress: false | |
| jobs: | |
| deploy: | |
| # Skip if this is a workflow push (to prevent infinite loops) | |
| if: github.actor != 'github-actions[bot]' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Cache build artifacts | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| .cache | |
| node_modules | |
| key: cheatsheetz-${{ runner.os }}-${{ hashFiles('package-lock.json') }}-${{ hashFiles('.cache/**') }} | |
| restore-keys: | | |
| cheatsheetz-${{ runner.os }}-${{ hashFiles('package-lock.json') }} | |
| cheatsheetz-${{ runner.os }}- | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build Next.js app | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NODE_ENV: production | |
| CI: true | |
| run: npm run build | |
| - name: Setup GitHub Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Upload Pages artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./out | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| - name: Output deployment URL | |
| run: echo "π Deployed to ${{ steps.deployment.outputs.page_url }}" |