1
+
1
2
name : Generate PDF Documentation
2
3
3
4
on :
4
5
pull_request :
5
6
branches :
6
7
- ' main'
7
8
- ' pdf-documentation'
8
- paths :
9
- - ' documentation/**'
10
- - ' .github/workflows/combined-docs-md-ci.yml'
11
9
workflow_dispatch :
12
10
inputs :
13
11
folder_path :
@@ -30,34 +28,23 @@ permissions:
30
28
jobs :
31
29
generate_docs :
32
30
runs-on : ubuntu-latest
31
+ outputs :
32
+ pdf_url : ${{ steps.s3_upload.outputs.s3_url }} # Output the S3 bucket URL where the generated PDF is stored
33
33
34
34
steps :
35
35
- name : Checkout repository
36
36
uses : actions/checkout@v4
37
37
38
- - name : Set repository name as an environment variable
39
- run : |
40
- echo "REPO_NAME=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2)" >> $GITHUB_ENV
38
+ - name : Install Node.js
39
+ uses : actions/setup-node@v4
40
+ with :
41
+ node-version : ' 20' # Specify the Node.js version you need
41
42
42
43
- name : Install Python
43
44
run : |
44
45
sudo apt-get update
45
46
sudo apt-get install -y python3 python3-pip
46
47
47
- - name : Read version from pyproject.toml or default to 0.0.0
48
- run : |
49
- pip install toml
50
- VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
51
- if [ -z "$VERSION" ]; then
52
- VERSION="0.0.0"
53
- fi
54
- echo "VERSION=${VERSION}" >> $GITHUB_ENV
55
-
56
- - name : Install Node.js
57
- uses : actions/setup-node@v4
58
- with :
59
- node-version : ' 20' # Specify the Node.js version you need
60
-
61
48
- name : Install LaTeX, Pandoc, and Required Packages
62
49
run : |
63
50
sudo apt-get install -y pandoc
68
55
sudo apt-get install texlive-fonts-extra
69
56
sudo apt-get install texlive-latex-extra
70
57
58
+ - name : Install Ghostscript
59
+ run : |
60
+ sudo apt-get install -y ghostscript
61
+
62
+ - name : Verify Ghostscript Installation
63
+ run : |
64
+ gs --version
65
+ which gs
66
+ echo "Ghostscript installation verified"
67
+
71
68
- name : Set environment variables
72
69
env :
73
70
FOLDER_PATH : ${{ github.event.inputs.folder_path || './docs' }} # For manual runs or PR body
80
77
echo "COMBINED_DOC_PATH=${COMBINED_DOC_PATH}" >> $GITHUB_ENV
81
78
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
82
79
80
+ # Fallback: Set the repository name as the documentation name if no title is found
81
+ - name : Set repository name as documentation name fallback
82
+ run : | # Extracts the repository name (everything after the slash in org/repo)
83
+ echo "REPO_NAME=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2)" >> $GITHUB_ENV
84
+
85
+ # Extract documentation title and determine the version number dynamically
86
+ - name : Extract title and version
87
+ run : |
88
+ DOC_TITLE=$(node -p "require('./documentation/makersaurus.config.js').title || ''")
89
+
90
+ if [[ "${{ env.FOLDER_PATH }}" == "./docs" ]]; then
91
+ VERSION=$(node -p "require('./documentation/makersaurus.config.js').versions?.current?.label || '0.0.0'")
92
+ else
93
+ VERSION=$(basename "${{ env.FOLDER_PATH }}" | sed 's/version-//')
94
+ fi
95
+
96
+ SAFE_TITLE=$(echo "$DOC_TITLE" | tr ' ' '_' | tr -dc 'A-Za-z0-9._-')
97
+
98
+ echo "DOC_TITLE=${DOC_TITLE}" >> $GITHUB_ENV
99
+ echo "VERSION=${VERSION}" >> $GITHUB_ENV
100
+ echo "SAFE_TITLE=${SAFE_TITLE}" >> $GITHUB_ENV
101
+
83
102
# Download the script from another repository (replace with correct repo and script path)
84
103
- name : Download script and make it executable
85
104
run : |
@@ -90,36 +109,61 @@ jobs:
90
109
chmod +x ./documentation/generate_pdf_doc.py
91
110
chmod +x ./documentation/parse_sidebar.js
92
111
93
- - name : Navigate to documentation directory and run script
112
+ # Generate either a combined markdown file or a PDF depending on the branch
113
+ - name : Generate combined markdown or PDF
94
114
run : |
95
115
cd documentation
96
116
if [[ "${{ env.BRANCH_NAME }}" =~ ^refs/heads/pdf-documentation ]]; then
97
117
python3 generate_pdf_doc.py "${{ env.FOLDER_PATH }}" "${{ env.SIDEBAR_PATH }}" "${{ env.COMBINED_DOC_PATH }}"
98
118
else
99
119
python3 generate_combined_md.py "${{ env.FOLDER_PATH }}" "${{ env.SIDEBAR_PATH }}"
100
120
fi
101
-
121
+
122
+ # Rename the generated output files to include the documentation title and version
123
+ - name : Rename output files
124
+ run : |
125
+ cd documentation
126
+ if [[ -f documentation.pdf ]]; then
127
+ mv documentation.pdf "${{ env.SAFE_TITLE }}_${{ env.VERSION }}.pdf"
128
+ fi
129
+ if [[ -f combined_docs.md ]]; then
130
+ mv combined_docs.md "${{ env.SAFE_TITLE }}_${{ env.VERSION }}.md"
131
+ fi
102
132
103
133
- name : Upload generated documentation
104
134
uses : actions/upload-artifact@v4
105
135
with :
106
136
name : documentation_artifacts
107
137
path : |
108
- documentation/combined_docs.md
109
- documentation/documentation.pdf
110
-
138
+ documentation/${{ env.SAFE_TITLE }}_${{ env.VERSION }}.md
139
+ documentation/${{ env.SAFE_TITLE }}_${{ env.VERSION }}.pdf
111
140
112
141
- name : Configure AWS credentials
113
142
uses : aws-actions/configure-aws-credentials@v4
114
143
with :
115
- role-to-assume : arn:aws:iam::730335347609 :role/GitHub-OIDC-Role
116
- role-session-name : h2oai -llm-studio-documentation
144
+ role-to-assume : arn:aws:iam::905418351423 :role/GitHub-OIDC-Role
145
+ role-session-name : h2o -llm-studio
117
146
aws-region : us-east-1
118
147
119
-
120
- - name : Publish documentation
148
+ - name : Publish documentation to S3
149
+ id : s3_upload
121
150
run : |
122
151
if [[ "${{ env.BRANCH_NAME }}" =~ ^refs/heads/pdf-documentation ]]; then
123
- mv documentation/documentation.pdf documentation/${{ env.REPO_NAME }}_${{ env.VERSION }}.pdf
124
- aws s3 cp documentation/${{ env.REPO_NAME }}_${{ env.VERSION }}.pdf s3://pdf-documentation/llm-studio-documentation/
152
+ aws s3 cp "documentation/${{ env.SAFE_TITLE }}_${{ env.VERSION }}.pdf" s3://pdf-documentation/h2o-llm-studio/
153
+
154
+ S3_BUCKET="pdf-documentation"
155
+ S3_KEY="h2o-llm-studio/${{ env.SAFE_TITLE }}_${{ env.VERSION }}.pdf"
156
+ S3_URL="https://${S3_BUCKET}.s3.amazonaws.com/${S3_KEY}"
157
+
158
+ echo "s3_url=${S3_URL}" >> $GITHUB_OUTPUT
159
+
160
+ echo "PDF uploaded successfully to: ${S3_URL}"
161
+ else
162
+ echo "Skipping S3 upload - not on pdf-documentation branch"
125
163
fi
164
+
165
+ - name : Display PDF URL
166
+ if : steps.s3_upload.outputs.s3_url != ''
167
+ run : |
168
+ echo "PDF is available at: ${{ steps.s3_upload.outputs.s3_url }}"
169
+ echo "pdf_url=${{ steps.s3_upload.outputs.s3_url }}" >> $GITHUB_ENV
0 commit comments