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,7 @@ 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+ bundle exec jekyll build --future --config _config_ci.yml,_config_theme .yml,${{ inputs.config_file }}
115137
116138 - name : Upload artifact
117139 uses : actions/upload-artifact@v4
@@ -132,12 +154,13 @@ jobs:
132154 - name : Checkout gh-pages
133155 uses : actions/checkout@v4
134156 with :
135- ref : gh-pages
157+ ref : ${{ inputs.target_branch }}
136158 path : gh-pages
137159 persist-credentials : false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token
138160 fetch-depth : 0 # otherwise, will fail to push refs to dest repo
139161
140162 - name : Clean
163+ if : ${{ inputs.clean_gh_pages }}
141164 run : |
142165 # empty contents of gh-pages
143166 rm -f -r ./gh-pages/*
@@ -159,6 +182,6 @@ jobs:
159182 author_email : ${{ secrets.GH_BOT_EMAIL }}
160183 author_name : ${{ secrets.GH_BOT_NAME }}
161184 directory : gh-pages
162- branch : gh-pages
185+ branch : ${{ inputs.target_branch }}
163186 force : false
164187 message : " Deploy site from ${{ github.sha }}"
0 commit comments