Skip to content

[Issues #8 and #9] ADRs for website framework and hosting #2

[Issues #8 and #9] ADRs for website framework and hosting

[Issues #8 and #9] ADRs for website framework and hosting #2

name: CD - Website (PR preview)
on:
pull_request:
paths:
- "website/**" # Trigger only if changes are in the 'website' directory
permissions:
contents: read
pages: write
id-token: write
pull-requests: write # Required for PR comments
jobs:
build:
runs-on: ubuntu-latest
# Skip job if the PR is from a fork
if: github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Set BASE_URL dynamically for each PR preview
- name: Install, build, and upload site
uses: withastro/action@v3
env:
BASE_URL: /pr-${{ github.event.pull_request.number }}/ # Dynamic base path for PR preview
with:
path: ./website # Path to the root of our Astro project
deploy:
needs: build
runs-on: ubuntu-latest
# Skip job if the PR is from a fork
if: github.event.pull_request.head.repo.full_name == github.repository
environment:
name: github-pages-preview # Use the new environment for PR previews
url: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-${{ github.event.pull_request.number }}/
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
# Add a comment to the PR with the preview link
- name: Comment Preview Link
uses: mshick/add-pr-comment@v2
with:
message: |
🌐 **Preview URL**: [View Preview](https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-${{ github.event.pull_request.number }}/)
repo-token: ${{ secrets.GITHUB_TOKEN }}