Skip to content

Commit 8895589

Browse files
authored
init
1 parent fc978b2 commit 8895589

8 files changed

Lines changed: 181 additions & 0 deletions

File tree

.editorconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
charset = utf-8
7+
indent_style = space
8+
indent_size = 2

.github/workflows/test.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI (Self-Test for ditac-epub-action)
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-epub:
11+
name: Build and Validate EPUB
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
# 1️⃣ Check out the repository (includes action + example content)
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
# 2️⃣ Run the action locally using the example DITA map
20+
- name: Run ditac EPUB Action
21+
uses: ./
22+
with:
23+
map: example/document.ditamap
24+
output: out/example.epub
25+
resources-dir: example/res
26+
format: epub3
27+
validate-with-epubcheck: 'true'
28+
29+
# 3️⃣ Upload result as artifact for inspection
30+
- name: Upload EPUB artifact
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: example-epub
34+
path: out/example.epub
35+
36+
# 4️⃣ Optional: show dir tree for debugging
37+
- name: List output files
38+
run: |
39+
echo "EPUB build complete. Output directory contents:"
40+
tree out || ls -R out

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
out/
2+
*.zip
3+
epubcheck-*/
4+
ditac-*/
5+
.DS_Store

action.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: 'Build EPUB with ditac'
2+
description: 'Convert a DITA map to EPUB/EPUB3 using XMLmind DITA Converter (ditac)'
3+
author: 'VT-Evia'
4+
branding:
5+
color: blue
6+
icon: book
7+
8+
inputs:
9+
map:
10+
description: 'Path to the DITA map (e.g., example/document.ditamap)'
11+
required: true
12+
output:
13+
description: 'Output EPUB path (e.g., out/book.epub)'
14+
required: true
15+
format:
16+
description: 'Target format: epub or epub3'
17+
required: false
18+
default: 'epub3'
19+
ditac-version:
20+
description: 'ditac version tag, e.g., 3_17_2'
21+
required: false
22+
default: '3_17_2'
23+
resources-dir:
24+
description: 'xsl-resources-directory (CSS/images); will be created if missing'
25+
required: false
26+
default: 'res'
27+
java-version:
28+
description: 'Java version to install (ditac supports Java 8+).'
29+
required: false
30+
default: '17'
31+
extra-args:
32+
description: 'Additional arguments passed to ditac (advanced).'
33+
required: false
34+
default: ''
35+
validate-with-epubcheck:
36+
description: 'Run EPUBCheck after build (true/false).'
37+
required: false
38+
default: 'true'
39+
epubcheck-version:
40+
description: 'EPUBCheck version (used if validate-with-epubcheck=true).'
41+
required: false
42+
default: '5.1.0'
43+
44+
runs:
45+
using: "composite"
46+
steps:
47+
- name: Set up Java
48+
uses: actions/setup-java@v4
49+
with:
50+
distribution: temurin
51+
java-version: ${{ inputs.java-version }}
52+
53+
- name: Restore ditac cache
54+
id: cache-ditac
55+
uses: actions/cache@v4
56+
with:
57+
path: ditac-${{ inputs.ditac-version }}
58+
key: ditac-${{ inputs.ditac-version }}
59+
60+
- name: Download ditac
61+
if: steps.cache-ditac.outputs.cache-hit != 'true'
62+
shell: bash
63+
run: |
64+
curl -fsSL -o ditac.zip "https://www.xmlmind.com/ditac/ditac-${{ inputs.ditac-version }}.zip"
65+
unzip -q ditac.zip
66+
rm -f ditac.zip
67+
68+
- name: Add ditac to PATH
69+
shell: bash
70+
run: echo "$GITHUB_WORKSPACE/ditac-${{ inputs.ditac-version }}/bin" >> "$GITHUB_PATH"
71+
72+
- name: Ensure directories
73+
shell: bash
74+
run: |
75+
mkdir -p "${{ inputs.resources-dir }}"
76+
mkdir -p "$(dirname "${{ inputs.output }}")"
77+
78+
- name: Build EPUB
79+
shell: bash
80+
run: |
81+
if [ "${{ inputs.format }}" = "epub3" ]; then FORMAT_OPT="-format epub3"; else FORMAT_OPT=""; fi
82+
set -e
83+
ditac -r . \
84+
-p xsl-resources-directory "${{ inputs.resources-dir }}" \
85+
$FORMAT_OPT \
86+
${{ inputs.extra-args }} \
87+
"${{ inputs.output }}" "${{ inputs.map }}"
88+
89+
- name: (Optional) Download EPUBCheck
90+
if: inputs.validate-with-epubcheck == 'true'
91+
shell: bash
92+
run: |
93+
curl -fsSL -o epubcheck.zip "https://github.com/w3c/epubcheck/releases/download/v${{ inputs.epubcheck-version }}/epubcheck-${{ inputs.epubcheck-version }}.zip"
94+
unzip -q epubcheck.zip
95+
rm -f epubcheck.zip
96+
echo "EPUBCHECK_JAR=$GITHUB_WORKSPACE/epubcheck-${{ inputs.epubcheck-version }}/epubcheck.jar" >> "$GITHUB_ENV"
97+
98+
- name: (Optional) Validate EPUB
99+
if: inputs.validate-with-epubcheck == 'true'
100+
shell: bash
101+
run: |
102+
# Fail on EPUBCheck errors; print report
103+
java -jar "$EPUBCHECK_JAR" "${{ inputs.output }}"

example/document.ditamap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd">
3+
<map title="Sample EPUB">
4+
<topicref href="topics/intro.dita"/>
5+
<topicref href="topics/chapter-1.dita"/>
6+
</map>

example/res/styles.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/* Basic EPUB styling example */
2+
body { font-family: serif; line-height: 1.5; }
3+
h1, h2, h3 { margin-top: 1.2em; }

example/topics/chapter-1.dita

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
3+
<topic id="chapter-1">
4+
<title>Chapter 1</title>
5+
<body>
6+
<p>EPUB 3 output can include CSS from the resources directory.</p>
7+
</body>
8+
</topic>

example/topics/intro.dita

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
3+
<topic id="intro">
4+
<title>Welcome</title>
5+
<body>
6+
<p>This is a minimal sample built with <b>ditac</b> inside GitHub Actions.</p>
7+
</body>
8+
</topic>

0 commit comments

Comments
 (0)