Skip to content

Commit

Permalink
ci(github): deploy to branch instead of artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
timmywil committed Sep 18, 2023
1 parent 54d903c commit ee7cdef
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,39 @@ jobs:
# Build job
build:
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_OPTIONS: '--max_old_space_size=4096'
run: npm run build -- --pathprefix="${{ steps.pages.outputs.base_path }}/"
# run: npm run build -- --pathprefix="/bugs.jquery.com/"
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./_site
run: npm run build -- --pathprefix="/bugs.jquery.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}"
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}"

0 comments on commit ee7cdef

Please sign in to comment.