Skip to content

Commit 832ed03

Browse files
committed
Replace the old gh-pages workflow with an action
This saves me having to maintain a separate path and the git commands used to force-push that, plus calling shell commands from Gradle doesn't work as well with the configuration cache and the general direction it's headed
1 parent 75b74f7 commit 832ed03

7 files changed

Lines changed: 57 additions & 45 deletions

File tree

.github/workflows/publish-docs.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: publish docs
2+
on:
3+
push:
4+
branches: ["main"]
5+
workflow_dispatch:
6+
permissions:
7+
contents: read
8+
pages: write
9+
id-token: write
10+
concurrency:
11+
group: "pages"
12+
cancel-in-progress: false
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v5
18+
- uses: gradle/actions/wrapper-validation@v5
19+
- uses: actions/setup-java@v5
20+
with:
21+
distribution: 'temurin'
22+
java-version: 25
23+
- run: ./gradlew :thymeleaf-layout-dialect-docs:copyGroovyDocs
24+
- uses: ruby/setup-ruby@4a9ddd6f338a97768b8006bf671dfbad383215f4 # https://github.com/ruby/setup-ruby/releases/tag/v1.207.0
25+
with:
26+
ruby-version: '3.1'
27+
bundler-cache: true
28+
cache-version: 0 # Increment this number if you need to re-download cached gems
29+
- run: bundle install
30+
working-directory: ./thymeleaf-layout-dialect-docs
31+
- run: bundle exec jekyll build --baseurl thymeleaf-layout-dialect
32+
working-directory: ./thymeleaf-layout-dialect-docs
33+
- uses: actions/upload-pages-artifact@v3
34+
with:
35+
path: './thymeleaf-layout-dialect-docs/_site'
36+
deploy:
37+
runs-on: ubuntu-latest
38+
needs: build
39+
steps:
40+
- uses: actions/deploy-pages@v4
41+
id: deployment
42+
environment:
43+
name: github-pages
44+
url: ${{ steps.deployment.outputs.page_url }}

thymeleaf-layout-dialect-docs/build.gradle

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/*
1+
/*
22
* Copyright 2019, Emanuel Rabina (http://www.ultraq.net.nz/)
3-
*
3+
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
*
7+
*
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,39 +28,7 @@ tasks.register('copyGroovyDocs', Copy) {
2828

2929
tasks.register('serveDocs', Exec) {
3030
dependsOn copyGroovyDocs
31-
commandLine 'bundle', 'exec', 'jekyll', 'serve', '--baseurl', ""
32-
}
33-
34-
tasks.register('publishDocs') {
35-
dependsOn copyGroovyDocs
36-
doLast {
37-
execute(["git", "init"])
38-
execute(["git", "checkout", "-b", "gh-pages"])
39-
execute(["git", "add", "_sass"])
40-
execute(["git", "add", "groovydoc", "--force"]) // Is in .gitignore but needed for docs
41-
execute(["git", "add", "processors"])
42-
execute(["git", "add", "_config.yml"])
43-
execute(["git", "add", "favicon.ico"])
44-
execute(["git", "add", "Gemfile*"])
45-
execute(["git", "add", "*.md"])
46-
execute(["git", "commit", "-m", "'Update docs'"])
47-
execute(["git", "push", "git@github.com:ultraq/thymeleaf-layout-dialect", "gh-pages", "--force"])
48-
execute(["rm", "-rf", ".git"])
49-
}
50-
}
51-
52-
/**
53-
* Execute an individual command and wait for the process to complete.
54-
*
55-
* @param command
56-
*/
57-
def execute(command) {
58-
println "Executing: ${command.join(" ")}"
59-
def proc = command.execute(null, projectDir)
60-
proc.waitForProcessOutput(System.out, System.err)
61-
if (proc.exitValue() > 0) {
62-
println "${proc.err.text}"
63-
}
31+
commandLine 'bundle', 'exec', 'jekyll', 'serve'
6432
}
6533

6634
tasks.register('cleanDocs', Exec) {

thymeleaf-layout-dialect-docs/configuration-options.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ new LayoutDialect()
2828
```
2929

3030
Sets how `<head>` elements will be sorted when combined from the layout and
31-
content templates. See [`<head>` element merging]({{ site.baseurl }}{% link processors/decorate.md %}#head-element-merging)
31+
content templates. See [`<head>` element merging]({% link processors/decorate.md %}#head-element-merging)
3232
for more details and examples.
3333

3434

@@ -43,7 +43,7 @@ new LayoutDialect()
4343
```
4444

4545
Bypass the layout dialect prforming any `<head>` element merging altogether.
46-
See [Bypassing <head> element merging altogether]({{ site.baseurl }}{% link processors/decorate.md %}#bypassing-head-element-merging-altogether)
46+
See [Bypassing <head> element merging altogether]({% link processors/decorate.md %}#bypassing-head-element-merging-altogether)
4747
for more details.
4848

4949

@@ -59,5 +59,5 @@ new LayoutDialect()
5959

6060
An experimental option added in 3.4.0 to use standard Thymeleaf expression
6161
syntax for title patterns instead of special tokens. See
62-
[Using standard Thymeleaf expression variables instead of special tokens]({{ site.baseurl }}{% link processors/title-pattern.md %}#using-standard-thymeleaf-expression-variables-instead-of-special-tokens)
62+
[Using standard Thymeleaf expression variables instead of special tokens]({% link processors/title-pattern.md %}#using-standard-thymeleaf-expression-variables-instead-of-special-tokens)
6363
for more details.

thymeleaf-layout-dialect-docs/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@ This will introduce the `layout` namespace, and 5 new attribute processors that
6565
you can use in your templates: `decorate`, `title-pattern`, `insert`, `replace`,
6666
and `fragment`.
6767

68-
Continue on to the [processors]({{ site.baseurl }}{% link processors/index.md %})
68+
Continue on to the [processors]({% link processors/index.md %})
6969
section to learn how to use these in your templates.

thymeleaf-layout-dialect-docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ When Thymeleaf processes your content template, the resulting HTML will be:
9898
Learn more
9999
----------
100100

101-
Check out the [getting started]({{ site.baseurl }}{% link getting-started.md %})
101+
Check out the [getting started]({% link getting-started.md %})
102102
guide to learn how to add the layout dialect to your Thymeleaf project, or the
103-
[processors]({{ site.baseurl}}{% link processors/index.md %}) pages for in-depth
103+
[processors]({% link processors/index.md %}) pages for in-depth
104104
examples of each of the layout dialect features and how they can help you build
105105
your templates.

thymeleaf-layout-dialect-docs/processors/insert.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@ the result would be this:
5959

6060
Note the surrounding `<div>` from the calling template remains. This is in line
6161
with how Thymeleaf's `th:insert` behaves. One way to remove the `<div>` would
62-
be to use [`layout:replace`]({{ site.baseurl }}{% link processors/replace.md %})
62+
be to use [`layout:replace`]({% link processors/replace.md %})
6363
instead, whose behaviour aligns with Thymeleaf's `th:replace`.

thymeleaf-layout-dialect-docs/processors/replace.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ the result would be this:
5555

5656
Note the `<div>` that included the `layout:replace` processor is gone. This is
5757
in line with how Thymeleaf's `th:replace` behaves. If you need to keep the
58-
original element, try [`layout:insert`]({{ site.baseurl }}{% link processors/insert.md %})
58+
original element, try [`layout:insert`]({% link processors/insert.md %})
5959
instead, whose behaviour aligns with Thymeleaf's `th:insert`.

0 commit comments

Comments
 (0)