Registry Auto Deploy #193
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 to GitHub Pages | |
| on: | |
| push: | |
| branches: [main] | |
| schedule: | |
| - cron: '0 * * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| check-changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_deploy: ${{ steps.check.outputs.should_deploy }} | |
| has_submodule_changes: ${{ steps.check.outputs.has_submodule_changes }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Detect changes | |
| id: check | |
| run: | | |
| echo "should_deploy=false" >> $GITHUB_OUTPUT | |
| echo "has_submodule_changes=false" >> $GITHUB_OUTPUT | |
| git submodule update --init --recursive --remote | |
| if ! git diff --quiet; then | |
| echo "Submodule changes detected!" | |
| git diff --stat | |
| echo "has_submodule_changes=true" >> $GITHUB_OUTPUT | |
| echo "should_deploy=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit submodule update | |
| if: steps.check.outputs.has_submodule_changes == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| git commit -m "Update registry submodule" | |
| # Push using the default GITHUB_TOKEN for this repo | |
| git push https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/${{ github.repository }}.git HEAD:main | |
| build: | |
| needs: check-changes | |
| if: needs.check-changes.outputs.should_deploy == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Build Astro site | |
| uses: withastro/action@v3 | |
| with: | |
| package-manager: bun@latest | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
| PUBLIC_SITE_NAME: Zig Index | |
| PUBLIC_SITE_URL: https://zig-index.github.io | |
| PUBLIC_REPO_URL: https://github.com/Zig-Index/zig-index.github.io | |
| - name: Upload Artifact for Pages | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./dist | |
| name: github-pages | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| environment: | |
| name: github-pages | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| uses: actions/deploy-pages@v4 |