Skip to content

Commit ee7cdef

Browse files
committed
ci(github): deploy to branch instead of artifacts
1 parent 54d903c commit ee7cdef

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

.github/workflows/deploy.yml

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,35 +29,39 @@ jobs:
2929
# Build job
3030
build:
3131
runs-on: ubuntu-latest
32+
env:
33+
DEPLOY_DIR: _site/
34+
DEPLOY_BRANCH: gh-pages
3235
steps:
3336
- name: Checkout
3437
uses: actions/checkout@v3
3538
with:
3639
submodules: recursive
37-
- name: Setup Pages
38-
id: pages
39-
uses: actions/configure-pages@v3
40+
41+
- name: Prepare deployment branch
42+
run: |
43+
mkdir "${DEPLOY_DIR}"
44+
cd "${DEPLOY_DIR}"
45+
# Clone and checkout existing branch, or initialise with a new and empty branch
46+
git clone --depth 5 --branch "${DEPLOY_BRANCH}" "https://github.com/${GITHUB_REPOSITORY}.git" . || git init -b "${DEPLOY_BRANCH}"
47+
4048
- name: Install Node.js dependencies
4149
run: npm ci
50+
4251
- name: Build with Eleventy
4352
env:
4453
NODE_ENV: production
4554
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.jquery.com/"
48-
- name: Upload artifact
49-
uses: actions/upload-pages-artifact@v1
50-
with:
51-
path: ./_site
55+
run: npm run build -- --pathprefix="/bugs.jquery.com/"
5256

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
57+
- name: Push to branch
58+
# Inspired by https://github.com/helaili/jekyll-action/blob/2.2.0/entrypoint.sh
59+
env:
60+
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
61+
run: |
62+
cd "${DEPLOY_DIR}"
63+
git config user.name "${GITHUB_ACTOR}" && \
64+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" && \
65+
git add . && \
66+
git commit --allow-empty -m "Build commit ${GITHUB_SHA}" && \
67+
git push "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "HEAD:${DEPLOY_BRANCH}"

0 commit comments

Comments
 (0)