Build and Deploy to GitHub Pages #114
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 and Deploy to GitHub Pages | |
| on: | |
| push: | |
| branches: | |
| - main | |
| schedule: | |
| - cron: '0 0 * * *' # Runs daily at midnight UTC | |
| workflow_dispatch: # Allow manual triggering | |
| permissions: | |
| contents: write | |
| jobs: | |
| build_and_deploy_job: | |
| runs-on: ubuntu-latest | |
| env: | |
| CI: true | |
| name: Build and Deploy Job | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Fetch Repos | |
| run: npm run fetch-data ${{ github.repository_owner }} | |
| if: github.repository != 'ProjectDepot/Gallery' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build Gallery | |
| run: npm run build | |
| if: github.repository != 'ProjectDepot/Gallery' | |
| env: | |
| VITE_GITHUB_ACTOR: ${{ github.repository_owner }} | |
| - name: Build Docs | |
| run: npm run docs:build | |
| if: github.repository == 'ProjectDepot/Gallery' | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ${{ github.repository == 'ProjectDepot/Gallery' && './docs/.vitepress/dist' || './dist' }} |