Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/astro-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI

on:
pull_request:
push:
branches: [main, master, dev, work]

permissions:
contents: read

jobs:
quality:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Astro
uses: withastro/action@v3
with:
path: .
node-version: 20
package-manager: npm

- name: Type/content check
run: npm run check

- name: Build site
run: npm run build
47 changes: 47 additions & 0 deletions .github/workflows/astro-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Deploy production site

on:
push:
branches: [main, master]
workflow_dispatch:

permissions:
contents: write

env:
PAGES_BRANCH: gh-pages

concurrency:
group: deploy-prod
cancel-in-progress: true

jobs:
deploy:
runs-on: ubuntu-latest
env:
DEPLOY_TARGET: prod

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Astro
uses: withastro/action@v3
with:
path: .
node-version: 20
package-manager: npm

- name: Build production site
run: npm run build

- name: Add .nojekyll for GitHub Pages
run: touch dist/.nojekyll

- name: Deploy to pages branch root
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: ${{ env.PAGES_BRANCH }}
folder: dist
clean: true
clean-exclude: preview
154 changes: 154 additions & 0 deletions .github/workflows/astro-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: Preview on Pull Request

on:
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
inputs:
pr_number:
description: "Pull request number to deploy preview for"
required: true
type: string

permissions:
contents: write
pull-requests: write

concurrency:
group: preview-${{ github.event.pull_request.number || inputs.pr_number }}
cancel-in-progress: true

env:
PAGES_BRANCH: gh-pages

jobs:
preview-deploy:
runs-on: ubuntu-latest
env:
PR_NUMBER: ${{ github.event.pull_request.number || inputs.pr_number }}
DEPLOY_TARGET: pr
DEPLOY_PREVIEW_PATH: pr-${{ github.event.pull_request.number || inputs.pr_number }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Ensure gh-pages branch exists
shell: bash
run: |
set -euo pipefail
git fetch --all
if git ls-remote --exit-code --heads origin "$PAGES_BRANCH" >/dev/null 2>&1; then
echo "Branch $PAGES_BRANCH exists"
exit 0
fi

git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout --orphan "$PAGES_BRANCH"
git rm -rf . >/dev/null 2>&1 || true
printf '<!doctype html><title>Bootstrap</title><p>Preview bootstrap.</p>' > index.html
touch .nojekyll
git add index.html .nojekyll
git commit -m "Bootstrap gh-pages for previews"
git push origin "$PAGES_BRANCH"

- name: Setup Astro
uses: withastro/action@v3
with:
path: .
node-version: 20
package-manager: npm

- name: Build site
run: npm run build

- name: Add .nojekyll for GitHub Pages
run: touch dist/.nojekyll

- name: Deploy PR preview to gh-pages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: ${{ env.PAGES_BRANCH }}
folder: dist
target-folder: preview/pr-${{ env.PR_NUMBER }}
clean: true

- name: Compute preview URL
id: preview_url
shell: bash
env:
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
run: |
set -euo pipefail
user_site_repo="${OWNER}.github.io"
if [ "$REPO" = "$user_site_repo" ]; then
url="https://${OWNER}.github.io/preview/pr-${PR_NUMBER}/"
else
url="https://${OWNER}.github.io/${REPO}/preview/pr-${PR_NUMBER}/"
fi
echo "url=$url" >> "$GITHUB_OUTPUT"

- name: Verify preview URL is reachable
id: verify_preview
continue-on-error: true
shell: bash
env:
PREVIEW_URL: ${{ steps.preview_url.outputs.url }}
run: |
set -euo pipefail
echo "Checking $PREVIEW_URL"
for i in $(seq 1 40); do
code=$(curl -s -L -o /dev/null -w "%{http_code}" "$PREVIEW_URL" || true)
if [ "$code" = "200" ]; then
echo "Preview is live"
exit 0
fi
echo "Attempt $i/40: HTTP $code, retrying in 15s..."
sleep 15
done
echo "Preview did not become reachable in time"
exit 1

- name: Comment preview URL on PR
if: github.event_name == 'pull_request' && steps.verify_preview.outcome == 'success'
uses: actions/github-script@v7
env:
PREVIEW_URL: ${{ steps.preview_url.outputs.url }}
with:
script: |
const pr = context.payload.pull_request.number;
const body = [
'🔍 PR preview is ready.',
'',
`**Open preview:** ${process.env.PREVIEW_URL}`
].join('\n');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr,
body
});

- name: Comment failure help on PR
if: github.event_name == 'pull_request' && steps.verify_preview.outcome == 'failure'
uses: actions/github-script@v7
env:
PREVIEW_URL: ${{ steps.preview_url.outputs.url }}
with:
script: |
const pr = context.payload.pull_request.number;
const body = [
'⚠️ PR preview was deployed but the URL was not reachable yet.',
'',
`Try opening: ${process.env.PREVIEW_URL}`,
'',
'If it still does not load, wait 2-5 minutes and re-run the `Preview on Pull Request` workflow.'
].join('\n');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr,
body
});
50 changes: 50 additions & 0 deletions .github/workflows/bootstrap-pages-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Bootstrap gh-pages branch

on:
workflow_dispatch:

permissions:
contents: write

jobs:
bootstrap:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Create gh-pages branch if missing
shell: bash
run: |
set -euo pipefail
git fetch --all

if git ls-remote --exit-code --heads origin gh-pages >/dev/null 2>&1; then
echo "gh-pages branch already exists; nothing to do."
exit 0
fi

git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

git checkout --orphan gh-pages
git rm -rf . >/dev/null 2>&1 || true

cat > index.html <<'HTML'
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Marcus Astro Pages Bootstrap</title>
</head>
<body>
<p>GitHub Pages bootstrap branch created. Deploy workflows will replace this content.</p>
</body>
</html>
HTML

touch .nojekyll
git add index.html .nojekyll
git commit -m "Bootstrap gh-pages branch"
git push origin gh-pages
74 changes: 0 additions & 74 deletions .github/workflows/hugo.yml

This file was deleted.

32 changes: 32 additions & 0 deletions MIGRATION_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Hugo -> Astro migration notes

## Status

This branch now includes a real Astro project (`package.json`, `astro.config.mjs`, `src/`) and Astro CI/deploy workflows.

## PR preview URLs (before merge)

- Every PR build deploys to `gh-pages` under `preview/pr-<number>/`.
- URL format:
- `https://<user>.github.io/<repo>/preview/pr-<number>/`
- The workflow comments preview status and URL on the PR.

## Production deploy

- Pushes to `main`/`master` build Astro and deploy `dist/` to `gh-pages` root.
- `clean-exclude: preview` preserves existing PR preview folders.

## Required GitHub Pages settings

In **Settings → Pages**:

1. Source: `Deploy from a branch`
2. Branch: `gh-pages`
3. Folder: `/(root)`

## Workflow files

- `.github/workflows/astro-ci.yml`
- `.github/workflows/astro-pages.yml`
- `.github/workflows/astro-preview.yml`
- `.github/workflows/bootstrap-pages-branch.yml`
Loading