|
| 1 | +name: Deploy to GitHub Pages |
| 2 | + |
| 3 | +on: |
| 4 | + # Runs on pushes targeting the default branch |
| 5 | + push: |
| 6 | + branches: [main] # Or your default branch, e.g., master |
| 7 | + # Allows you to run this workflow manually from the Actions tab |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + pages: write |
| 14 | + id-token: write |
| 15 | + |
| 16 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 17 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 18 | +concurrency: |
| 19 | + group: "pages" |
| 20 | + cancel-in-progress: false |
| 21 | + |
| 22 | +jobs: |
| 23 | + build: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v4 |
| 28 | + - name: Set up Node.js |
| 29 | + uses: actions/setup-node@v4 |
| 30 | + with: |
| 31 | + node-version: 18 # Or the Node.js version specified in your project |
| 32 | + cache: "npm" |
| 33 | + - name: Install dependencies |
| 34 | + run: npm ci |
| 35 | + - name: Build |
| 36 | + # Make sure your astro.config.mjs has the correct 'site' and 'base' |
| 37 | + # For GitHub Pages, if your repo is at https://github.com/USER/REPO, |
| 38 | + # site should be 'https://USER.github.io' and base should be '/REPO/' |
| 39 | + run: npm run build |
| 40 | + - name: Setup Pages |
| 41 | + uses: actions/configure-pages@v4 |
| 42 | + - name: Upload artifact |
| 43 | + uses: actions/upload-pages-artifact@v3 |
| 44 | + with: |
| 45 | + # Upload entire repository |
| 46 | + path: "./dist" # Astro builds to 'dist' by default |
| 47 | + |
| 48 | + deploy: |
| 49 | + environment: |
| 50 | + name: github-pages |
| 51 | + url: ${{ steps.deployment.outputs.page_url }} |
| 52 | + runs-on: ubuntu-latest |
| 53 | + needs: build |
| 54 | + steps: |
| 55 | + - name: Deploy to GitHub Pages |
| 56 | + id: deployment |
| 57 | + uses: actions/deploy-pages@v4 |
0 commit comments