Deploy to GitHub Pages #4
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 | |
| paths: | |
| - 'site/**' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: 'pages' | |
| cancel-in-progress: false | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Fetch latest release version | |
| id: version | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| RELEASE_TAG=$(gh release view --json tagName --jq '.tagName' 2>/dev/null || echo "") | |
| if [ -n "$RELEASE_TAG" ]; then | |
| VERSION="${RELEASE_TAG#v}" | |
| echo "Found release version: $VERSION" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| else | |
| echo "No releases found, keeping default version" | |
| echo "version=" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Inject version into site | |
| if: steps.version.outputs.version != '' | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| echo "Updating softwareVersion to $VERSION in site/index.html" | |
| sed -i 's/"softwareVersion": "[^"]*"/"softwareVersion": "'"$VERSION"'"/' site/index.html | |
| grep -o '"softwareVersion": "[^"]*"' site/index.html | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v4 | |
| with: | |
| path: './site' | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |