Merge pull request #71 from dgunzy/website #1
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 Documentation | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'docs/**' | |
| - '.github/workflows/docs.yml' | |
| workflow_dispatch: | |
| # Allow manual triggering | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Needed for git info | |
| - name: Setup Hugo | |
| uses: peaceiris/actions-hugo@v2 | |
| with: | |
| hugo-version: 'latest' | |
| extended: true | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.21' | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: docs/package-lock.json | |
| - name: Install Go dependencies | |
| working-directory: docs | |
| run: | | |
| go mod download | |
| go mod tidy | |
| - name: Install npm dependencies | |
| working-directory: docs | |
| run: | | |
| npm ci | |
| - name: Fetch metadata | |
| working-directory: docs | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| mkdir -p scripts | |
| chmod +x scripts/fetch-metadata.sh || true | |
| ./scripts/fetch-metadata.sh static/metadata.json || echo "Metadata fetch failed, continuing..." | |
| - name: Build Hugo site | |
| working-directory: docs | |
| run: | | |
| hugo --minify --baseURL "https://dgunzy.github.io/flux9s/" | |
| - name: Copy metadata.json to public | |
| working-directory: docs | |
| run: | | |
| if [ -f static/metadata.json ]; then | |
| cp static/metadata.json public/metadata.json | |
| else | |
| echo '{"crates_downloads": 0, "github_stars": 0, "github_releases": 0, "last_updated": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' > public/metadata.json | |
| fi | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: docs/public | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |