Skip to content

Commit 9dad7cb

Browse files
committed
Refactor build-docs workflow to enhance artifact handling
Introduced dynamic artifact naming with environment variables, simplifying configuration and improving flexibility. Removed redundant "ls" steps and streamlined artifact paths for clarity. Updated Algolia artifact processing to align with the new approach.
1 parent ef85e8e commit 9dad7cb

File tree

1 file changed

+46
-26
lines changed

1 file changed

+46
-26
lines changed

.github/workflows/build-docs.yml

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,47 @@ permissions:
1212
pages: write
1313

1414
env:
15-
INSTANCE: 'Writerside/rw'
16-
ARTIFACT: 'webHelpRW2-all.zip'
17-
DOCKER_VERSION: '241.15989'
18-
ALGOLIA_ARTIFACT: 'webHelpRW2-all.zip'
19-
ALGOLIA_APP_NAME: 'S1V9Y61PCC'
20-
ALGOLIA_INDEX_NAME: 'prod_WIKI'
21-
ALGOLIA_KEY: '${{ secrets.ALGOLIA_KEY }}'
22-
CONFIG_JSON_PRODUCT: 'RW'
23-
CONFIG_JSON_VERSION: '1.0'
15+
INSTANCE: "Writerside/rw"
16+
ARTIFACT: "webHelpRW2-all.zip"
17+
DOCKER_VERSION: "241.15989"
18+
ALGOLIA_ARTIFACT: "webHelpRW2-all.zip"
19+
ALGOLIA_APP_NAME: "S1V9Y61PCC"
20+
ALGOLIA_INDEX_NAME: "prod_WIKI"
21+
ALGOLIA_KEY: "${{ secrets.ALGOLIA_KEY }}"
22+
CONFIG_JSON_PRODUCT: "RW"
23+
CONFIG_JSON_VERSION: "1.0"
2424

2525
jobs:
2626
build:
2727
runs-on: ubuntu-latest
28+
outputs:
29+
algolia_artifact: ${{ steps.define-ids.outputs.algolia_artifact }}
30+
artifact: ${{ steps.define-ids.outputs.artifact }}
2831
steps:
2932
- name: Checkout repository
3033
uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0
36+
37+
- name: Define instance id and artifacts
38+
id: define-ids
39+
run: |
40+
INSTANCE=${INSTANCE#*/}
41+
INSTANCE_ID_UPPER=$(echo "$INSTANCE" | tr '[:lower:]' '[:upper:]')
42+
ARTIFACT="webHelp${INSTANCE_ID_UPPER}2-all.zip"
43+
ALGOLIA_ARTIFACT="algolia-indexes-${INSTANCE_ID_UPPER}.zip"
44+
45+
# Print the values
46+
echo "INSTANCE_ID_UPPER: $INSTANCE_ID_UPPER"
47+
echo "ARTIFACT: $ARTIFACT"
48+
echo "ALGOLIA_ARTIFACT: $ALGOLIA_ARTIFACT"
49+
50+
# Set the environment variables and outputs
51+
echo "INSTANCE_ID_UPPER=$INSTANCE_ID_UPPER" >> $GITHUB_ENV
52+
echo "ARTIFACT=$ARTIFACT" >> $GITHUB_ENV
53+
echo "ALGOLIA_ARTIFACT=$ALGOLIA_ARTIFACT" >> $GITHUB_ENV
54+
echo "artifact=$ARTIFACT" >> $GITHUB_OUTPUT
55+
echo "algolia_artifact=$ALGOLIA_ARTIFACT" >> $GITHUB_OUTPUT
3156
3257
- name: Build docs using Writerside Docker builder
3358
uses: JetBrains/writerside-github-action@v4
@@ -43,6 +68,7 @@ jobs:
4368
path: |
4469
artifacts/${{ env.ARTIFACT }}
4570
artifacts/report.json
71+
artifacts/${{ env.ALGOLIA_ARTIFACT }}
4672
retention-days: 7
4773

4874
test:
@@ -55,9 +81,6 @@ jobs:
5581
name: docs
5682
path: artifacts
5783

58-
- name: List artifacts directory (test step)
59-
run: ls -l
60-
6184
- name: Test documentation
6285
uses: JetBrains/writerside-checker-action@v1
6386
with:
@@ -74,15 +97,10 @@ jobs:
7497
uses: actions/download-artifact@v4
7598
with:
7699
name: docs
77-
78-
- name: List artifacts directory (deploy step)
79-
run: ls -l
100+
path: artifacts
80101

81102
- name: Unzip artifact
82-
run: unzip -O UTF-8 -qq "${{ env.ARTIFACT }}" -d dir
83-
84-
- name: List artifacts directory (deploy step)
85-
run: ls -l dir
103+
run: unzip -O UTF-8 -qq "artifacts/${{ needs.build.outputs.artifact }}" -d dir
86104

87105
- name: Setup Pages
88106
uses: actions/configure-pages@v4
@@ -107,20 +125,22 @@ jobs:
107125
with:
108126
name: docs
109127
path: artifacts
128+
110129
- name: Unzip Algolia artifact
111130
run: unzip -O UTF-8 -qq "artifacts/${{ needs.build.outputs.algolia_artifact }}" -d algolia-indexes
131+
112132
- name: Update Algolia Index
113133
run: |
114134
if [ -z "${{ secrets.ALGOLIA_KEY }}" ]; then
115135
echo "ALGOLIA_KEY secret is not set in GitHub Secrets"
116136
exit 1
117137
else
118138
env "algolia-key=${{ secrets.ALGOLIA_KEY }}" java -jar /opt/builder/help-publication-agent.jar \
119-
update-index \
120-
--application-name ${{ env.ALGOLIA_APP_NAME }} \
121-
--index-name ${{ env.ALGOLIA_INDEX_NAME }} \
122-
--product ${{ env.CONFIG_JSON_PRODUCT }} \
123-
--version ${{ env.CONFIG_JSON_VERSION }} \
124-
--index-directory algolia-indexes/ \
125-
2>&1 | tee algolia-update-index-log.txt
139+
update-index \
140+
--application-name ${{ env.ALGOLIA_APP_NAME }} \
141+
--index-name ${{ env.ALGOLIA_INDEX_NAME }} \
142+
--product ${{ env.CONFIG_JSON_PRODUCT }} \
143+
--version ${{ env.CONFIG_JSON_VERSION }} \
144+
--index-directory algolia-indexes/ \
145+
2>&1 | tee algolia-update-index-log.txt
126146
fi

0 commit comments

Comments
 (0)