feat(build): use jekyll and restyle website #425
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Build | |
on: | |
pull_request: | |
branches: [master] | |
types: [opened, synchronize, reopened] | |
push: | |
branches: [master] | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build Jekyll | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout theme | |
uses: actions/checkout@v4 | |
with: | |
repository: LizardByte/LizardByte.github.io | |
ref: ${{ github.repository == 'LizardByte/LizardByte.github.io' && github.ref || 'master' }} | |
submodules: recursive | |
path: theme | |
- name: Checkout repo | |
if: ${{ github.repository != 'LizardByte/LizardByte.github.io' }} | |
uses: actions/checkout@v4 | |
with: | |
path: project | |
- name: Setup project | |
if: ${{ github.repository }} == 'LizardByte/LizardByte.github.io' | |
run: | | |
mkdir -p ./project | |
cp -r ./theme ./project/ | |
- name: Create site | |
run: | | |
pwd | |
base_dirs=( | |
./theme/third-party/beautiful-jekyll | |
./theme | |
) | |
targets=( | |
_data | |
_includes | |
_layouts | |
_sass | |
assets | |
404.html | |
_config.yml | |
*.gemspec | |
feed.xml | |
Gemfile | |
staticman.yml | |
tags.html | |
) | |
for base_dir in "${base_dirs[@]}"; do | |
for target in "${targets[@]}"; do | |
if [ -e "$base_dir/$target" ]; then | |
cp -rf "$base_dir/$target" ./ | |
fi | |
done | |
done | |
# copy project directory, they should only come from the project repo | |
cp -rf ./project/. ./ | |
# remove theme and project directories, they are no longer needed | |
rm -rf theme project | |
# debug contents recursively | |
ls -Ra | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '3.3' | |
- name: Install dependencies | |
run: | | |
bundle install | |
- name: Setup Pages | |
id: configure-pages | |
uses: actions/configure-pages@v5 | |
- name: Setup CI config | |
run: | | |
echo "---" > _config_ci.yml | |
echo "baseurl: ${{ steps.configure-pages.outputs.base_path }}" >> _config_ci.yml | |
- name: Build site | |
env: | |
JEKYLL_ENV: production | |
PAGES_REPO_NWO: ${{ github.repository }} | |
run: | | |
bundle exec jekyll build --future --config _config_ci.yml,_config.yml | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: site | |
path: _site | |
if-no-files-found: error | |
retention-days: 1 | |
deploy: | |
name: Deploy to Pages | |
if: >- | |
(github.event_name == 'push' && github.ref == 'refs/heads/master') || | |
(github.event_name == 'workflow_dispatch') | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout gh-pages | |
uses: actions/checkout@v4 | |
with: | |
ref: gh-pages | |
path: gh-pages | |
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token | |
fetch-depth: 0 # otherwise, will fail to push refs to dest repo | |
- name: Clean | |
run: | | |
# empty contents of gh-pages | |
rm -f -r ./gh-pages/* | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: site | |
path: gh-pages | |
- name: no-jekyll | |
run: | | |
touch gh-pages/.nojekyll | |
- name: Deploy to gh-pages | |
uses: actions-js/[email protected] | |
with: | |
github_token: ${{ secrets.GH_BOT_TOKEN }} | |
author_email: ${{ secrets.GH_BOT_EMAIL }} | |
author_name: ${{ secrets.GH_BOT_NAME }} | |
directory: gh-pages | |
branch: gh-pages | |
force: false | |
message: "Deploy site from ${{ github.sha }}" |