1+ name : Build documentation
2+
3+ on :
4+ push :
5+ branches : ["main"]
6+ workflow_dispatch :
7+
8+ permissions :
9+ contents : read
10+ id-token : write
11+ pages : write
12+
13+ env :
14+ INSTANCE : ' Writerside/t'
15+ DOCKER_VERSION : ' 243.22562'
16+ PDF : ' PDF.xml'
17+ ALGOLIA_APP_NAME : ' B4IMCNPNHK'
18+ ALGOLIA_INDEX_NAME : ' Tutoriales'
19+ CONFIG_JSON_PRODUCT : ' t'
20+ CONFIG_JSON_VERSION : ' 2.0'
21+
22+ jobs :
23+ build :
24+ runs-on : ubuntu-latest
25+ outputs :
26+ algolia_artifact : ${{ steps.define-ids.outputs.algolia_artifact }}
27+ artifact : ${{ steps.define-ids.outputs.artifact }}
28+ steps :
29+ - name : Checkout repository
30+ uses : actions/checkout@v4
31+ with :
32+ fetch-depth : 0
33+
34+ - name : Define instance id and artifacts
35+ id : define-ids
36+ run : |
37+ INSTANCE=${INSTANCE#*/}
38+ INSTANCE_ID_UPPER=$(echo "$INSTANCE" | tr '[:lower:]' '[:upper:]')
39+ ARTIFACT="webHelp${INSTANCE_ID_UPPER}2-all.zip"
40+ ALGOLIA_ARTIFACT="algolia-indexes-${INSTANCE_ID_UPPER}.zip"
41+
42+ # Print the values
43+ echo "INSTANCE_ID_UPPER: $INSTANCE_ID_UPPER"
44+ echo "ARTIFACT: $ARTIFACT"
45+ echo "ALGOLIA_ARTIFACT: $ALGOLIA_ARTIFACT"
46+
47+ # Set the environment variables and outputs
48+ echo "INSTANCE_ID_UPPER=$INSTANCE_ID_UPPER" >> $GITHUB_ENV
49+ echo "ARTIFACT=$ARTIFACT" >> $GITHUB_ENV
50+ echo "ALGOLIA_ARTIFACT=$ALGOLIA_ARTIFACT" >> $GITHUB_ENV
51+ echo "artifact=$ARTIFACT" >> $GITHUB_OUTPUT
52+ echo "algolia_artifact=$ALGOLIA_ARTIFACT" >> $GITHUB_OUTPUT
53+
54+ - name : Build docs using Writerside Docker builder
55+ uses : JetBrains/writerside-github-action@v4
56+ with :
57+ instance : ${{ env.INSTANCE }}
58+ docker-version : ${{ env.DOCKER_VERSION }}
59+
60+ - name : Save artifact with build results
61+ uses : actions/upload-artifact@v4
62+ with :
63+ name : docs
64+ path : |
65+ artifacts/${{ steps.define-ids.outputs.artifact }}
66+ artifacts/report.json
67+ artifacts/${{ steps.define-ids.outputs.algolia_artifact }}
68+ retention-days : 7
69+ test :
70+ needs : build
71+ runs-on : ubuntu-latest
72+ steps :
73+ - name : Download artifacts
74+ uses : actions/download-artifact@v4
75+ with :
76+ name : docs
77+ path : artifacts
78+
79+ - name : Test documentation
80+ uses : JetBrains/writerside-checker-action@v1
81+ with :
82+ instance : ${{ env.INSTANCE }}
83+ deploy :
84+ environment :
85+ name : github-pages
86+ url : ${{ steps.deployment.outputs.page_url }}
87+ needs : [build, test]
88+ runs-on : ubuntu-latest
89+ steps :
90+ - name : Download artifacts
91+ uses : actions/download-artifact@v4
92+ with :
93+ name : docs
94+ path : artifacts
95+
96+ - name : Unzip artifact
97+ run : unzip -O UTF-8 -qq "artifacts/${{ needs.build.outputs.artifact }}" -d dir
98+
99+ - name : Setup Pages
100+ uses : actions/configure-pages@v4
101+
102+ - name : Package and upload Pages artifact
103+ uses : actions/upload-pages-artifact@v3
104+ with :
105+ path : dir
106+
107+ - name : Deploy to GitHub Pages
108+ id : deployment
109+ uses : actions/deploy-pages@v4
110+ publish-indexes :
111+ needs : [build, test, deploy]
112+ runs-on : ubuntu-latest
113+ container :
114+ image : registry.jetbrains.team/p/writerside/builder/algolia-publisher:2.0.32-3
115+ steps :
116+ - name : Download artifact
117+ uses : actions/download-artifact@v4
118+ with :
119+ name : docs
120+ path : artifacts
121+ - name : Unzip Algolia artifact
122+ run : unzip -O UTF-8 -qq "artifacts/${{ needs.build.outputs.algolia_artifact }}" -d algolia-indexes
123+ - name : Update Algolia Index
124+ run : |
125+ if [ -z "${{ secrets.ALGOLIA_KEY }}" ]; then
126+ echo "ALGOLIA_KEY secret is not set in GitHub Secrets"
127+ exit 1
128+ else
129+ env "algolia-key=${{ secrets.ALGOLIA_KEY }}" java -jar /opt/builder/help-publication-agent.jar \
130+ update-index \
131+ --application-name ${{ env.ALGOLIA_APP_NAME }} \
132+ --index-name ${{ env.ALGOLIA_INDEX_NAME }} \
133+ --product ${{ env.CONFIG_JSON_PRODUCT }} \
134+ --version ${{ env.CONFIG_JSON_VERSION }} \
135+ --index-directory algolia-indexes/ \
136+ 2>&1 | tee algolia-update-index-log.txt
137+ fi
138+ build-pdf :
139+ runs-on : ubuntu-latest
140+ steps :
141+ - name : Checkout repository
142+ uses : actions/checkout@v4
143+ with :
144+ fetch-depth : 0
145+
146+ - name : Define instance ID
147+ run : |
148+ INSTANCE_ID="${INSTANCE#*/}"
149+ INSTANCE_ID_UPPER=$(echo "$INSTANCE_ID" | tr '[:lower:]' '[:upper:]')
150+ echo "INSTANCE_ID_UPPER=$INSTANCE_ID_UPPER" >> $GITHUB_ENV
151+ echo "Extracted ID: $INSTANCE_ID_UPPER"
152+
153+ - name : Build Writerside docs using Docker
154+ uses : JetBrains/writerside-github-action@v4
155+ with :
156+ instance : ${{ env.INSTANCE }}
157+ docker-version : ${{ env.DOCKER_VERSION }}
158+ pdf : ${{ env.PDF }}
159+
160+ - name : Upload artifact
161+ uses : actions/upload-artifact@v4
162+ with :
163+ name : artifact
164+ path : |
165+ artifacts/pdfSource${{ env.INSTANCE_ID_UPPER }}.pdf
166+ artifacts/pdfSource${{ env.INSTANCE_ID_UPPER }}.html
167+ retention-days : 7
0 commit comments