From e9a5efa8c4044ae591de2c54f52f520bfabb548c Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Feb 2026 06:04:15 +0000 Subject: [PATCH 1/2] Add GitLab CI/CD pipeline to auto-publish site to GitHub Pages --- .gitlab-ci.yml | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..ea61bef --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,49 @@ +# GitLab CI/CD pipeline — builds the Quarto site and deploys to GitHub Pages +# +# REQUIRED: Before this pipeline can run, add a secret variable in GitLab: +# GitLab project → Settings → CI/CD → Variables +# Key: GITHUB_TOKEN +# Value: a GitHub Personal Access Token with "repo" scope (Contents: Read and Write) +# Flags: check "Mask variable" so it never appears in logs + +stages: + - deploy + +publish: + stage: deploy + image: ubuntu:22.04 + + variables: + QUARTO_VERSION: "1.6.39" + # Prevent git from asking interactive questions + GIT_TERMINAL_PROMPT: "0" + + before_script: + # Install the bare minimum needed to download and run Quarto + - apt-get update -qq + - apt-get install -y --no-install-recommends wget git ca-certificates + # Download and install Quarto + - wget -q "https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-amd64.deb" + - dpkg -i "quarto-${QUARTO_VERSION}-linux-amd64.deb" + - rm "quarto-${QUARTO_VERSION}-linux-amd64.deb" + # Verify install + - quarto --version + + script: + # Build the site — outputs static HTML to _site/ + - quarto render + + # Deploy _site/ to the gh-pages branch on GitHub + - git config --global user.email "gitlab-ci@noreply" + - git config --global user.name "GitLab CI" + - cd _site + - git init + - git checkout -b gh-pages + - git add . + - git commit -m "Deploy: $(date -u '+%Y-%m-%d %H:%M:%S UTC')" + # GITHUB_TOKEN is the secret variable you added in GitLab settings + - git push --force "https://x-token:${GITHUB_TOKEN}@github.com/pbhusari/quarto-personal-website.git" gh-pages + + # Only run this pipeline when changes are pushed to main + rules: + - if: '$CI_COMMIT_BRANCH == "main"' From 5b47dc5a6f15431f293388a9001720b39df5c064 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Feb 2026 06:05:05 +0000 Subject: [PATCH 2/2] Use quarto publish gh-pages instead of manual git push --- .gitlab-ci.yml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ea61bef..833b9b2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,7 @@ # REQUIRED: Before this pipeline can run, add a secret variable in GitLab: # GitLab project → Settings → CI/CD → Variables # Key: GITHUB_TOKEN -# Value: a GitHub Personal Access Token with "repo" scope (Contents: Read and Write) +# Value: a GitHub Personal Access Token with "Contents: Read and Write" permission # Flags: check "Mask variable" so it never appears in logs stages: @@ -30,19 +30,12 @@ publish: - quarto --version script: - # Build the site — outputs static HTML to _site/ - - quarto render - - # Deploy _site/ to the gh-pages branch on GitHub - git config --global user.email "gitlab-ci@noreply" - git config --global user.name "GitLab CI" - - cd _site - - git init - - git checkout -b gh-pages - - git add . - - git commit -m "Deploy: $(date -u '+%Y-%m-%d %H:%M:%S UTC')" - # GITHUB_TOKEN is the secret variable you added in GitLab settings - - git push --force "https://x-token:${GITHUB_TOKEN}@github.com/pbhusari/quarto-personal-website.git" gh-pages + # Repoint origin to GitHub with the auth token so quarto publish can push there + - git remote set-url origin "https://x-token:${GITHUB_TOKEN}@github.com/pbhusari/quarto-personal-website.git" + # quarto publish renders the site and pushes _site/ to the gh-pages branch in one step + - quarto publish gh-pages --no-prompt # Only run this pipeline when changes are pushed to main rules: