Skip to content

Merge pull request #73 from miloshb/content #66

Merge pull request #73 from miloshb/content

Merge pull request #73 from miloshb/content #66

name: Production Pipeline
on:
push:
branches: [ main, stage ]
pull_request:
branches: [ main, stage ]
jobs:
# JOB 1: Test and validate everything first
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.14.0'
cache: 'npm'
- name: Install Dependencies
run: npm ci
- name: Compile Production Astro Build
run: npm run build
env:
ASTRO_SITE: https://studiosunandsea.com
- name: Assert Sitemap & Robots.txt Alignment
run: |
if [ ! -f ./dist/sitemap-index.xml ]; then
echo "❌ ERROR: sitemap-index.xml missing!"
exit 1
fi
if ! grep -q "Sitemap: https://studiosunandsea.com" ./dist/robots.txt; then
echo "❌ ERROR: robots.txt missing sitemap reference!"
exit 1
fi
- name: Run Dynamic Sitemap URL Validation
run: npm run test:sitemap
- name: Scan Entire Site for Broken Internal Links
# start-server-and-test securely spins up the http-server, runs linkinator, catches real errors, and terminates gracefully on runner crash or test completion
run: npm run test:links
# LIVE EDGE REDIRECT RUNNER: Executes exclusively on production merge environments
- name: Install Playwright Browsers (Production Only)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: npx playwright install --with-deps chromium
- name: Execute Live Edge Domain Redirect Checks (Production Only)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: npm run test:redirects
# JOB 2: Only run version bumping if the validation job passes AND it's the main branch
bump-version:
runs-on: ubuntu-latest
needs: validate
# Only bump on merges to main
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: write # Allows the action to push changes back to GitHub
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required to see commit history cleanly
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.14.0'
cache: 'npm'
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# This reads the commit message. If it contains [major] or [minor], it bumps accordingly.
# Otherwise, it defaults to a standard patch bump (0.0.2 -> 0.0.3).
- name: Evaluate Commits & Bump Version
run: |
COMMIT_MSG=$(git log -1 --pretty=%B)
if [[ "$COMMIT_MSG" == *"[major]"* ]]; then
npm version major -m "chore: bump version to %s [skip ci]"
elif [[ "$COMMIT_MSG" == *"[minor]"* ]]; then
npm version minor -m "chore: bump version to %s [skip ci]"
else
npm version patch -m "chore: bump version to %s [skip ci]"
fi
- name: Push Version Update to GitHub
run: |
git push origin main --follow-tags