-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (119 loc) · 4.13 KB
/
jekyll-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Publish jekyll on Pages
on:
workflow_call:
inputs:
working-directory:
description: 'The working directory where the Jekyll site is located'
default: docs
type: string
publish:
description: 'Publish the site to GitHub Pages'
required: true
default: false
type: boolean
publish-branch:
description: 'The branch to publish the site to - empty use the actions based workflow'
default: ''
type: string
validate-html:
description: 'Validate the HTML of the site'
required: false
default: false
type: boolean
validate-html-args:
description: 'Arguments to pass to html-proofer'
required: false
default: ''
type: string
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
name: Build with Jekyll
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.working-directory}}
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup Ruby
uses: ruby/setup-ruby@4a9ddd6f338a97768b8006bf671dfbad383215f4 # v1.207.0
with:
working-directory: ${{ inputs.working-directory }}
bundler-cache: true
- name: Setup Pages
id: pages
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0
- name: Build with Jekyll
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
env:
JEKYLL_ENV: production
- name: Verify that htmlproofer is available
if: ${{ inputs.validate-html }}
run: |
if ! bundle exec htmlproofer --version; then
echo "htmlproofer is not available - please add it to your Gemfile with:"
echo 'gem "html-proofer", "~> 5.0.0"'
exit 1
fi
- name: Verify html with htmlproofer
if: ${{ inputs.validate-html }}
run: >-
bundle exec htmlproofer ./_site
--swap-urls 'https\://${{ steps.pages.outputs.host }}${{ steps.pages.outputs.base_path }}/:/,^${{ steps.pages.outputs.base_path }}/:/'
--typhoeus='{"cookiefile":".cookies","cookiejar":".cookies"}'
--hydra='{"max_concurrency": 1}'
${{ inputs.validate-html-args }}
- name: Upload artifact
if: ${{ inputs.publish }}
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1
with:
path: "${{ inputs.working-directory }}/_site/"
deploy:
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
if: ${{ inputs.publish && inputs.publish-branch == '' }}
concurrency:
group: pages
cancel-in-progress: true
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
deploy-as-branch:
name: Deploy to GitHub Pages branch
runs-on: ubuntu-latest
if: ${{ inputs.publish && inputs.publish-branch != '' }}
permissions:
contents: write
concurrency:
group: pages
cancel-in-progress: true
needs: build
steps:
- name: Checkout specific branch
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: ${{ inputs.publish-branch }}
- name: Fetch artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: github-pages
path: /tmp/pages/
- name: Unpack artifact
run: |
tar xvf /tmp/pages/artifact.tar
ls -la
- name: Commit and push changes to ${{ inputs.publish-branch }} branch
uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842 # v5.0.1
with:
commit_message: "Update jekyll site"
branch: ${{ inputs.publish-branch }}