|
| 1 | +name: Deploy Docs to Github Pages |
| 2 | + |
| 3 | +on: |
| 4 | + # Runs on pushes targeting the default branch |
| 5 | + push: |
| 6 | + branches: ["main"] |
| 7 | + |
| 8 | + # Allows you to run this workflow manually from the Actions tab |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + pages: write |
| 15 | + id-token: write |
| 16 | + |
| 17 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 18 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 19 | +concurrency: |
| 20 | + group: "pages" |
| 21 | + cancel-in-progress: false |
| 22 | + |
| 23 | +env: |
| 24 | + BUILD_PATH: "./docs" # Astro project is in docs folder |
| 25 | + |
| 26 | +jobs: |
| 27 | + build: |
| 28 | + name: Build |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + - name: Checkout |
| 32 | + uses: actions/checkout@v4 |
| 33 | + - name: Setup Node |
| 34 | + uses: actions/setup-node@v4 |
| 35 | + with: |
| 36 | + node-version: "20" |
| 37 | + cache: npm |
| 38 | + cache-dependency-path: ${{ env.BUILD_PATH }}/package-lock.json |
| 39 | + - name: Setup Pages |
| 40 | + id: pages |
| 41 | + uses: actions/configure-pages@v5 |
| 42 | + - name: Install dependencies |
| 43 | + run: npm ci |
| 44 | + working-directory: ${{ env.BUILD_PATH }} |
| 45 | + - name: Build with Astro |
| 46 | + run: | |
| 47 | + npx --no-install astro build \ |
| 48 | + --site "${{ steps.pages.outputs.origin }}" \ |
| 49 | + --base "${{ steps.pages.outputs.base_path }}" |
| 50 | + working-directory: ${{ env.BUILD_PATH }} |
| 51 | + - name: Upload artifact |
| 52 | + uses: actions/upload-pages-artifact@v3 |
| 53 | + with: |
| 54 | + path: ${{ env.BUILD_PATH }}/dist |
| 55 | + |
| 56 | + deploy: |
| 57 | + environment: |
| 58 | + name: github-pages |
| 59 | + url: ${{ steps.deployment.outputs.page_url }} |
| 60 | + needs: build |
| 61 | + runs-on: ubuntu-latest |
| 62 | + name: Deploy |
| 63 | + steps: |
| 64 | + - name: Deploy to GitHub Pages |
| 65 | + id: deployment |
| 66 | + uses: actions/deploy-pages@v4 |
0 commit comments