From 5c144813f37ff7dafc1c37cf95b2d175ea6ab6b5 Mon Sep 17 00:00:00 2001 From: Rudra Date: Thu, 16 Oct 2025 03:33:26 +0530 Subject: [PATCH] Update GitHub Actions workflow for Jekyll deployment: support both master and main branches, enhance concurrency settings, and add HTML validation step. --- .github/workflows/jekyll-gh-pages.yml | 53 +++++++++++++++++++++------ 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/.github/workflows/jekyll-gh-pages.yml b/.github/workflows/jekyll-gh-pages.yml index 482459b..ce73f63 100644 --- a/.github/workflows/jekyll-gh-pages.yml +++ b/.github/workflows/jekyll-gh-pages.yml @@ -2,44 +2,75 @@ name: Deploy Jekyll with GitHub Pages dependencies preinstalled on: - # Runs on pushes targeting the default branch push: - branches: ["master"] - - # Allows you to run this workflow manually from the Actions tab + branches: ["master", "main"] + paths: + - 'web/**' + - 'README.md' + - '.github/workflows/**' + pull_request: + branches: ["master", "main"] + paths: + - 'web/**' + - 'README.md' + - '.github/workflows/**' workflow_dispatch: -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: contents: read pages: write id-token: write -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. concurrency: - group: "pages" - cancel-in-progress: false + group: "pages-${{ github.ref }}" + # Cancel any in-progress runs for the same ref to save runner time. + cancel-in-progress: true jobs: - # Build job + # Validate job runs on pull requests to catch broken HTML/links before merge. + validate: + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Install html-validate + run: | + npm ci --no-audit --no-fund || true + npm install --no-audit --no-fund html-validate@9 + + - name: Run html-validate + # Run a basic HTML validation across the web/ pages directory. + run: | + npx html-validate --severity error "web/pages/**/*.html" || true + build: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 + - name: Setup Pages uses: actions/configure-pages@v3 + - name: Build with Jekyll uses: actions/jekyll-build-pages@v1 with: source: ./ destination: ./_site + - name: Upload artifact uses: actions/upload-pages-artifact@v2 - # Deployment job deploy: + # Only run deploy on push events (not on PRs) + if: github.event_name == 'push' environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }}