11---
2- name : Build
2+ name : Build Jekyll
33
44on :
5- pull_request :
6- branches : [master]
7- types : [opened, synchronize, reopened]
8- push :
9- branches : [master]
10- workflow_dispatch :
11-
12- concurrency :
13- group : ${{ github.workflow }}-${{ github.ref }}
14- cancel-in-progress : true
5+ workflow_call :
6+ inputs :
7+ site_source :
8+ description : ' Directory where the site source files are located'
9+ required : false
10+ default : ' .'
11+ type : string
12+ config_file :
13+ description : ' Configuration file to use, relative to the site source directory'
14+ required : false
15+ default : ' _config.yml'
16+ type : string
17+ target_branch :
18+ description : ' Branch to deploy to. Branch must already exist.'
19+ required : false
20+ default : ' gh-pages'
21+ type : string
22+ clean_gh_pages :
23+ description : ' Clean gh-pages before deploying'
24+ required : false
25+ default : true
26+ type : boolean
27+ secrets :
28+ GH_BOT_EMAIL :
29+ description : ' Email address of the bot account'
30+ required : true
31+ GH_BOT_NAME :
32+ description : ' Name of the bot account'
33+ required : true
34+ GH_BOT_TOKEN :
35+ description : ' Personal access token of the bot account'
36+ required : true
1537
1638jobs :
1739 build :
5880 _sass
5981 assets
6082 404.html
61- _config .yml
83+ _config_theme .yml
6284 favicon.ico
6385 feed.xml
6486 Gemfile
7597 done
7698
7799 # copy project directory, they should only come from the project repo
78- cp -RTf ./project/ ${TMPDIR}/
100+ cp -RTf ./project/${{ inputs.site_source }}/ ${TMPDIR}/
79101
80102 # remove the workspace
81103 cd ..
@@ -111,7 +133,13 @@ jobs:
111133 JEKYLL_ENV : production
112134 PAGES_REPO_NWO : ${{ github.repository }}
113135 run : |
114- bundle exec jekyll build --future --config _config_ci.yml,_config.yml
136+ # if inputs.config_file exists
137+ config_files="_config_ci.yml,_config_theme.yml"
138+ if [ -e "${{ inputs.config_file }}" ]; then
139+ config_files="${config_files},${{ inputs.config_file }}"
140+ fi
141+
142+ bundle exec jekyll build --future --config ${config_files}
115143
116144 - name : Upload artifact
117145 uses : actions/upload-artifact@v4
@@ -132,12 +160,13 @@ jobs:
132160 - name : Checkout gh-pages
133161 uses : actions/checkout@v4
134162 with :
135- ref : gh-pages
163+ ref : ${{ inputs.target_branch }}
136164 path : gh-pages
137165 persist-credentials : false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token
138166 fetch-depth : 0 # otherwise, will fail to push refs to dest repo
139167
140168 - name : Clean
169+ if : ${{ inputs.clean_gh_pages }}
141170 run : |
142171 # empty contents of gh-pages
143172 rm -f -r ./gh-pages/*
@@ -159,6 +188,6 @@ jobs:
159188 author_email : ${{ secrets.GH_BOT_EMAIL }}
160189 author_name : ${{ secrets.GH_BOT_NAME }}
161190 directory : gh-pages
162- branch : gh-pages
191+ branch : ${{ inputs.target_branch }}
163192 force : false
164193 message : " Deploy site from ${{ github.sha }}"
0 commit comments