Skip to content

Commit

Permalink
ci(github): deploy site to gh-pages branch
Browse files Browse the repository at this point in the history
  • Loading branch information
timmywil committed Sep 22, 2023
1 parent aeb6ff9 commit d4bfee6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
55 changes: 29 additions & 26 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ name: Deploy site
on:
# Runs on pushes targeting the default branch
push:
branches: ['main']
branches: ['ci-test']

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
contents: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
Expand All @@ -26,38 +25,42 @@ defaults:
shell: bash

jobs:
# Build job
build:
deploy:
runs-on: ubuntu-latest
env:
DEPLOY_DIR: _site/
DEPLOY_BRANCH: gh-pages
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3

- name: Prepare deployment branch
run: |
mkdir "${DEPLOY_DIR}"
cd "${DEPLOY_DIR}"
# Clone and checkout existing branch, or initialise with a new and empty branch
git clone --depth 5 --branch "${DEPLOY_BRANCH}" "https://github.com/${GITHUB_REPOSITORY}.git" . || git init -b "${DEPLOY_BRANCH}"
- name: Install Node.js dependencies
run: npm ci

- name: Build with Eleventy
env:
NODE_ENV: production
NODE_ENV: development
NODE_OPTIONS: '--max_old_space_size=4096'
run: npm run build -- --pathprefix="${{ steps.pages.outputs.base_path }}/"
# run: npm run build -- --pathprefix="/bugs.jqueryui.com/"
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./_site
run: npm run build -- --pathprefix="/bugs.jqueryui.com/"

# Deployment job
deploy:
environment:
name: github-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@v2
- name: Push to branch
# Inspired by https://github.com/helaili/jekyll-action/blob/2.2.0/entrypoint.sh
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
run: |
cd "${DEPLOY_DIR}"
touch .nojekyll
git config user.name "${GITHUB_ACTOR}" && \
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" && \
git add . && \
git commit --allow-empty -m "Build commit ${GITHUB_SHA}" && \
git push "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "HEAD:${DEPLOY_BRANCH}"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Static archive of the old bugs.jqueryui.com trac site, built with eleventy.",
"scripts": {
"clean": "rimraf _site/",
"build": "npm run clean && npx @11ty/eleventy",
"build": "npx @11ty/eleventy",
"postbuild": "npm run searchindex",
"start": "npm run clean && cross-env NODE_ENV=development npx @11ty/eleventy --serve --quiet",
"debug": "npm run clean && DEBUG=Eleventy* npx @11ty/eleventy",
Expand Down

0 comments on commit d4bfee6

Please sign in to comment.