Skip to content

Commit d7c308e

Browse files
authored
docs: Update combined-docs-md-ci.yml (#930)
1 parent 60cda3b commit d7c308e

File tree

2 files changed

+75
-31
lines changed

2 files changed

+75
-31
lines changed
Lines changed: 75 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1+
12
name: Generate PDF Documentation
23

34
on:
45
pull_request:
56
branches:
67
- 'main'
78
- 'pdf-documentation'
8-
paths:
9-
- 'documentation/**'
10-
- '.github/workflows/combined-docs-md-ci.yml'
119
workflow_dispatch:
1210
inputs:
1311
folder_path:
@@ -30,34 +28,23 @@ permissions:
3028
jobs:
3129
generate_docs:
3230
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
3333

3434
steps:
3535
- name: Checkout repository
3636
uses: actions/checkout@v4
3737

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
4142

4243
- name: Install Python
4344
run: |
4445
sudo apt-get update
4546
sudo apt-get install -y python3 python3-pip
4647
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-
6148
- name: Install LaTeX, Pandoc, and Required Packages
6249
run: |
6350
sudo apt-get install -y pandoc
@@ -68,6 +55,16 @@ jobs:
6855
sudo apt-get install texlive-fonts-extra
6956
sudo apt-get install texlive-latex-extra
7057
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+
7168
- name: Set environment variables
7269
env:
7370
FOLDER_PATH: ${{ github.event.inputs.folder_path || './docs' }} # For manual runs or PR body
@@ -80,6 +77,28 @@ jobs:
8077
echo "COMBINED_DOC_PATH=${COMBINED_DOC_PATH}" >> $GITHUB_ENV
8178
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
8279
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+
83102
# Download the script from another repository (replace with correct repo and script path)
84103
- name: Download script and make it executable
85104
run: |
@@ -90,36 +109,61 @@ jobs:
90109
chmod +x ./documentation/generate_pdf_doc.py
91110
chmod +x ./documentation/parse_sidebar.js
92111
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
94114
run: |
95115
cd documentation
96116
if [[ "${{ env.BRANCH_NAME }}" =~ ^refs/heads/pdf-documentation ]]; then
97117
python3 generate_pdf_doc.py "${{ env.FOLDER_PATH }}" "${{ env.SIDEBAR_PATH }}" "${{ env.COMBINED_DOC_PATH }}"
98118
else
99119
python3 generate_combined_md.py "${{ env.FOLDER_PATH }}" "${{ env.SIDEBAR_PATH }}"
100120
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
102132
103133
- name: Upload generated documentation
104134
uses: actions/upload-artifact@v4
105135
with:
106136
name: documentation_artifacts
107137
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
111140
112141
- name: Configure AWS credentials
113142
uses: aws-actions/configure-aws-credentials@v4
114143
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
117146
aws-region: us-east-1
118147

119-
120-
- name: Publish documentation
148+
- name: Publish documentation to S3
149+
id: s3_upload
121150
run: |
122151
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"
125163
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

documentation/cover_page.pdf

33.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)