Skip to content

Commit d4bfee6

Browse files
committed
ci(github): deploy site to gh-pages branch
1 parent aeb6ff9 commit d4bfee6

File tree

2 files changed

+30
-27
lines changed

2 files changed

+30
-27
lines changed

.github/workflows/deploy.yml

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ name: Deploy site
33
on:
44
# Runs on pushes targeting the default branch
55
push:
6-
branches: ['main']
6+
branches: ['ci-test']
77

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

1111
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1212
permissions:
13-
contents: read
14-
pages: write
13+
contents: write
1514
id-token: write
1615

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

2827
jobs:
29-
# Build job
30-
build:
28+
deploy:
3129
runs-on: ubuntu-latest
30+
env:
31+
DEPLOY_DIR: _site/
32+
DEPLOY_BRANCH: gh-pages
3233
steps:
3334
- name: Checkout
3435
uses: actions/checkout@v3
3536
with:
3637
submodules: recursive
37-
- name: Setup Pages
38-
id: pages
39-
uses: actions/configure-pages@v3
38+
39+
- name: Prepare deployment branch
40+
run: |
41+
mkdir "${DEPLOY_DIR}"
42+
cd "${DEPLOY_DIR}"
43+
# Clone and checkout existing branch, or initialise with a new and empty branch
44+
git clone --depth 5 --branch "${DEPLOY_BRANCH}" "https://github.com/${GITHUB_REPOSITORY}.git" . || git init -b "${DEPLOY_BRANCH}"
45+
4046
- name: Install Node.js dependencies
4147
run: npm ci
48+
4249
- name: Build with Eleventy
4350
env:
44-
NODE_ENV: production
51+
NODE_ENV: development
4552
NODE_OPTIONS: '--max_old_space_size=4096'
46-
run: npm run build -- --pathprefix="${{ steps.pages.outputs.base_path }}/"
47-
# run: npm run build -- --pathprefix="/bugs.jqueryui.com/"
48-
- name: Upload artifact
49-
uses: actions/upload-pages-artifact@v1
50-
with:
51-
path: ./_site
53+
run: npm run build -- --pathprefix="/bugs.jqueryui.com/"
5254

53-
# Deployment job
54-
deploy:
55-
environment:
56-
name: github-pages
57-
url: ${{ steps.deployment.outputs.page_url }}
58-
runs-on: ubuntu-latest
59-
needs: build
60-
steps:
61-
- name: Deploy to GitHub Pages
62-
id: deployment
63-
uses: actions/deploy-pages@v2
55+
- name: Push to branch
56+
# Inspired by https://github.com/helaili/jekyll-action/blob/2.2.0/entrypoint.sh
57+
env:
58+
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
59+
run: |
60+
cd "${DEPLOY_DIR}"
61+
touch .nojekyll
62+
git config user.name "${GITHUB_ACTOR}" && \
63+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" && \
64+
git add . && \
65+
git commit --allow-empty -m "Build commit ${GITHUB_SHA}" && \
66+
git push "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "HEAD:${DEPLOY_BRANCH}"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Static archive of the old bugs.jqueryui.com trac site, built with eleventy.",
55
"scripts": {
66
"clean": "rimraf _site/",
7-
"build": "npm run clean && npx @11ty/eleventy",
7+
"build": "npx @11ty/eleventy",
88
"postbuild": "npm run searchindex",
99
"start": "npm run clean && cross-env NODE_ENV=development npx @11ty/eleventy --serve --quiet",
1010
"debug": "npm run clean && DEBUG=Eleventy* npx @11ty/eleventy",

0 commit comments

Comments
 (0)