Skip to content

Refactor Jekyll GitHub Actions workflow artifact handling #77

Refactor Jekyll GitHub Actions workflow artifact handling

Refactor Jekyll GitHub Actions workflow artifact handling #77

Workflow file for this run

name: Deploy Jekyll site to Pages
on:
push:
branches: ["source"]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4.1'
bundler-cache: true
cache-version: 1
- name: Setup Pages
id: pages
uses: actions/configure-pages@v4
with:
enablement: true
- name: Build with Jekyll
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
env:
JEKYLL_ENV: production
- name: Verify _site Directory
run: ls -la _site
- name: Check Artifact Size
run: du -sh _site
- name: Remove Symlinks
run: find _site -type l -delete
- name: Remove Hard Links
run: find _site -type f -links +1 -exec cp --remove-destination {} {}.tmp \; -exec mv {}.tmp {} \;
- name: Archive artifact
shell: sh
if: runner.os == 'Linux'
run: |
chmod -c -R +rX "_site" |
while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
tar \
--dereference --hard-dereference \
--directory "_site" \
-cvf "$RUNNER_TEMP/artifact.tar" \
--exclude=.git \
--exclude=.github \
.
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: github-pages
path: _site
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: github-pages
path: ${{ runner.temp }}
- name: Extract Artifact
run: |
mkdir -p _site # Ensure _site directory exists
tar -xvf $RUNNER_TEMP/artifact.tar -C _site
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
with:
artifact-name: github-pages