Skip to content

Commit 8e38310

Browse files
feat(build): use jekyll and restyle website (#186)
1 parent bd71bb4 commit 8e38310

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1614
-1589
lines changed

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# ignore hidden files
2+
.*
3+
4+
!.well-known/
5+
6+
third-party/beautiful-jekyll/_posts/
7+
8+
_site/

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# ensure dockerfiles are checked out with LF line endings
2+
Dockerfile text eol=lf
3+
*.dockerfile text eol=lf

.github/workflows/build.yml

Lines changed: 0 additions & 69 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
name: Jekyll CI
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- master
8+
types:
9+
- opened
10+
- synchronize
11+
- reopened
12+
push:
13+
branches:
14+
- master
15+
16+
concurrency:
17+
group: "${{ github.workflow }}-${{ github.ref }}"
18+
cancel-in-progress: true
19+
20+
jobs:
21+
call-jekyll-build:
22+
uses: ./.github/workflows/jekyll-build.yml
23+
with:
24+
target_branch: gh-pages
25+
clean_gh_pages: true
26+
secrets:
27+
GH_BOT_EMAIL: ${{ secrets.GH_BOT_EMAIL }}
28+
GH_BOT_NAME: ${{ secrets.GH_BOT_NAME }}
29+
GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
30+
31+
release:
32+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Setup Release
36+
id: setup-release
37+
uses: LizardByte/[email protected]
38+
with:
39+
github_token: ${{ secrets.GH_BOT_TOKEN }}
40+
41+
- name: Create Release
42+
id: action
43+
uses: LizardByte/[email protected]
44+
with:
45+
allowUpdates: false
46+
artifacts: ''
47+
body: ${{ steps.setup-release.outputs.release_body }}
48+
generateReleaseNotes: ${{ steps.setup-release.outputs.release_generate_release_notes }}
49+
name: ${{ steps.setup-release.outputs.release_tag }}
50+
prerelease: true
51+
tag: ${{ steps.setup-release.outputs.release_tag }}
52+
token: ${{ secrets.GH_BOT_TOKEN }}

.github/workflows/jekyll-build.yml

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
---
2+
name: Build Jekyll
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
site_artifact:
8+
description: 'Artifact name to download'
9+
required: false
10+
default: ''
11+
type: string
12+
extract_archive:
13+
description: |
14+
Name of nested archive to extract. In some cases you may want to upload a zip of files to reduce
15+
upload size and time. If you do this, you must specify the name of the archive to extract.
16+
required: false
17+
default: ''
18+
type: string
19+
config_file:
20+
description: 'Configuration file to use, relative to the site source directory'
21+
required: false
22+
default: '_config.yml'
23+
type: string
24+
target_branch:
25+
description: 'Branch to deploy to. Branch must already exist.'
26+
required: false
27+
default: 'gh-pages'
28+
type: string
29+
clean_gh_pages:
30+
description: 'Clean gh-pages before deploying'
31+
required: false
32+
default: true
33+
type: boolean
34+
theme_ref:
35+
description: 'Branch, tag, or commit SHA of the theme repository to use'
36+
required: false
37+
default: 'master'
38+
type: string
39+
secrets:
40+
GH_BOT_EMAIL:
41+
description: 'Email address of the bot account'
42+
required: true
43+
GH_BOT_NAME:
44+
description: 'Name of the bot account'
45+
required: true
46+
GH_BOT_TOKEN:
47+
description: 'Personal access token of the bot account'
48+
required: true
49+
50+
jobs:
51+
build:
52+
name: Build Jekyll
53+
runs-on: ubuntu-latest
54+
steps:
55+
- name: Input validation
56+
run: |
57+
error=false
58+
if [ "${{ inputs.site_artifact }}" == 'site' ]; then
59+
echo "Artifact name cannot be 'site'"
60+
error=true
61+
fi
62+
63+
if [ "$error" = true ]; then
64+
exit 1
65+
fi
66+
67+
- name: Checkout theme
68+
uses: actions/checkout@v4
69+
with:
70+
repository: LizardByte/LizardByte.github.io
71+
ref: ${{ github.repository == 'LizardByte/LizardByte.github.io' && github.ref || inputs.theme_ref }}
72+
submodules: recursive
73+
path: theme
74+
75+
- name: Download input artifact
76+
if: ${{ inputs.site_artifact != '' }}
77+
uses: actions/download-artifact@v4
78+
with:
79+
name: ${{ inputs.site_artifact }}
80+
path: project
81+
82+
- name: Extract archive
83+
if: ${{ inputs.site_artifact != '' && inputs.extract_archive != '' }}
84+
working-directory: project
85+
run: |
86+
case "${{ inputs.extract_archive }}" in
87+
*.tar.gz|*.tgz)
88+
tar -xzf ${{ inputs.extract_archive }} -C .
89+
;;
90+
*.tar)
91+
tar -xf ${{ inputs.extract_archive }} -C .
92+
;;
93+
*.zip)
94+
unzip ${{ inputs.extract_archive }} -d .
95+
;;
96+
*)
97+
echo "Unsupported archive format"
98+
exit 1
99+
;;
100+
esac
101+
rm -f ${{ inputs.extract_archive }}
102+
103+
- name: Setup project
104+
if: ${{ github.repository == 'LizardByte/LizardByte.github.io' }}
105+
run: |
106+
mkdir -p ./project
107+
cp -RT ./theme/ ./project/
108+
rm -rf ./project/third-party
109+
110+
- name: Create site
111+
env:
112+
TMPDIR: /home/runner/work/tmp
113+
run: |
114+
mkdir -p ${TMPDIR}
115+
116+
base_dirs=(
117+
./theme/third-party/beautiful-jekyll
118+
./theme
119+
)
120+
121+
targets=(
122+
*.gemspec
123+
_data
124+
_includes
125+
_layouts
126+
_sass
127+
assets
128+
404.html
129+
_config_theme.yml
130+
favicon.ico
131+
feed.xml
132+
Gemfile
133+
staticman.yml
134+
tags.html
135+
)
136+
137+
for base_dir in "${base_dirs[@]}"; do
138+
for target in "${targets[@]}"; do
139+
if [ -e "$base_dir/$target" ]; then
140+
cp -rf "$base_dir/$target" ${TMPDIR}/
141+
fi
142+
done
143+
done
144+
145+
# copy project directory, they should only come from the project repo
146+
cp -RTf ./project/ ${TMPDIR}/
147+
148+
# remove the workspace
149+
cd ..
150+
rm -rf ${GITHUB_WORKSPACE}
151+
152+
# move the temporary directory to the workspace
153+
mv ${TMPDIR} ${GITHUB_WORKSPACE}
154+
cd ${GITHUB_WORKSPACE}
155+
156+
# debug contents recursively
157+
ls -Ra
158+
159+
- name: Setup Ruby
160+
uses: ruby/setup-ruby@v1
161+
with:
162+
ruby-version: '3.3'
163+
164+
- name: Install dependencies
165+
run: |
166+
bundle install
167+
168+
- name: Setup Pages
169+
id: configure-pages
170+
uses: actions/configure-pages@v5
171+
172+
- name: Setup CI config
173+
run: |
174+
echo "---" > _config_ci.yml
175+
echo "baseurl: ${{ steps.configure-pages.outputs.base_path }}" >> _config_ci.yml
176+
177+
- name: Build site
178+
env:
179+
JEKYLL_ENV: production
180+
PAGES_REPO_NWO: ${{ github.repository }}
181+
run: |
182+
# if inputs.config_file exists
183+
config_files="_config_ci.yml,_config_theme.yml"
184+
if [ -e "${{ inputs.config_file }}" ]; then
185+
config_files="${config_files},${{ inputs.config_file }}"
186+
fi
187+
188+
bundle exec jekyll build --future --config ${config_files}
189+
190+
- name: Upload artifact
191+
uses: actions/upload-artifact@v4
192+
with:
193+
name: site
194+
path: _site
195+
if-no-files-found: error
196+
include-hidden-files: true
197+
retention-days: 1
198+
199+
deploy:
200+
name: Deploy to Pages
201+
if: >-
202+
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
203+
(github.event_name == 'schedule') ||
204+
(github.event_name == 'workflow_dispatch')
205+
runs-on: ubuntu-latest
206+
needs: build
207+
steps:
208+
- name: Checkout gh-pages
209+
uses: actions/checkout@v4
210+
with:
211+
ref: ${{ inputs.target_branch }}
212+
path: gh-pages
213+
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token
214+
fetch-depth: 0 # otherwise, will fail to push refs to dest repo
215+
216+
- name: Clean
217+
if: ${{ inputs.clean_gh_pages }}
218+
run: |
219+
# empty contents of gh-pages
220+
rm -f -r ./gh-pages/*
221+
222+
- name: Download artifact
223+
uses: actions/download-artifact@v4
224+
with:
225+
name: site
226+
path: gh-pages
227+
228+
- name: no-jekyll
229+
run: |
230+
touch gh-pages/.nojekyll
231+
232+
- name: Deploy to gh-pages
233+
uses: actions-js/[email protected]
234+
with:
235+
github_token: ${{ secrets.GH_BOT_TOKEN }}
236+
author_email: ${{ secrets.GH_BOT_EMAIL }}
237+
author_name: ${{ secrets.GH_BOT_NAME }}
238+
directory: gh-pages
239+
branch: ${{ inputs.target_branch }}
240+
force: false
241+
message: "Deploy site from ${{ github.sha }}"

.gitignore

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
# ignore JetBrains project
22
.idea/
33

4-
# ignore node modules
5-
node_modules/
6-
package-lock.json
7-
8-
# ignore duplicated dist folder for localization
9-
dist/en
10-
dist/es-ES
4+
_site/

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "third-party/beautiful-jekyll"]
2+
path = third-party/beautiful-jekyll
3+
url = https://github.com/ReenigneArcher/beautiful-jekyll.git
4+
branch = master

0 commit comments

Comments
 (0)