Skip to content

Update staging-deploy.yml #7

Update staging-deploy.yml

Update staging-deploy.yml #7

Workflow file for this run

name: Deploy Staging Site
on:
# This ensures the action ONLY runs when code is pushed to the 'staging' branch
push:
branches:
- staging
# Allows manual triggering from the Actions tab
workflow_dispatch:
# Grant necessary permissions for deployment
permissions:
contents: read
pages: write
id-token: write
jobs:
# 1. Build Job: Builds the Jekyll static site
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
# This step sets up Ruby and Jekyll dependencies
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
working-directory: docs # <--- Tell Git to look inside 'docs'
bundler-cache: true
# *** MODIFIED STEP 1: ADD working-directory ***
- name: Install dependencies
working-directory: docs # <--- Tell Git to look inside 'docs'
run: bundle install
# *** MODIFIED STEP 2: ADD working-directory ***
- name: Build Jekyll site for Staging
working-directory: docs # <--- Tell Git to look inside 'docs'
# The `--source` argument is now redundant but harmless since we're already in 'docs'
run: bundle exec jekyll build --destination ../_site --baseurl /nhstech/staging
# 3. Upload Artifact Job: Uploads the built site from the default Jekyll output folder (_site)
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: '_site' # Jekyll outputs the built site here
# 4. Deployment Job: Deploys the artifact to the 'staging' subfolder
deploy:
environment:
name: staging-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
with:
# CRITICAL STEP: Deploy to the 'staging' path within GitHub Pages
target_path: staging