Skip to content

Commit ef85e8e

Browse files
committed
Refactor Algolia publish step in build-docs workflow
Simplified artifact handling and improved error checking in the Algolia index publishing process. Replaced redundant steps with streamlined commands and ensured better verification of secrets. This enhances readability and robustness of the workflow.
1 parent 08205af commit ef85e8e

File tree

1 file changed

+19
-24
lines changed

1 file changed

+19
-24
lines changed

.github/workflows/build-docs.yml

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ env:
1919
ALGOLIA_APP_NAME: 'S1V9Y61PCC'
2020
ALGOLIA_INDEX_NAME: 'prod_WIKI'
2121
ALGOLIA_KEY: '${{ secrets.ALGOLIA_KEY }}'
22-
CONFIG_JSON_PRODUCT: 'rw'
22+
CONFIG_JSON_PRODUCT: 'RW'
2323
CONFIG_JSON_VERSION: '1.0'
2424

2525
jobs:
@@ -97,7 +97,7 @@ jobs:
9797
uses: actions/deploy-pages@v4
9898

9999
publish-indexes:
100-
needs: [build, test, deploy]
100+
needs: [ build, test, deploy ]
101101
runs-on: ubuntu-latest
102102
container:
103103
image: registry.jetbrains.team/p/writerside/builder/algolia-publisher:2.0.32-3
@@ -106,26 +106,21 @@ jobs:
106106
uses: actions/download-artifact@v4
107107
with:
108108
name: docs
109-
110-
- name: List artifacts directory (publish step)
111-
run: ls -l
112-
113-
- name: Unzip artifact
114-
run: |
115-
unzip -O UTF-8 -qq "${{ env.ALGOLIA_ARTIFACT }}" -d algolia-indexes
116-
117-
- name: Check algolia-indexes directory
118-
run: |
119-
echo "Checking contents of algolia-indexes:"
120-
ls -l algolia-indexes || (echo "Directory 'algolia-indexes' does not exist or is empty!" && exit 1)
121-
122-
- name: Publish to Algolia Index (Debug)
109+
path: artifacts
110+
- name: Unzip Algolia artifact
111+
run: unzip -O UTF-8 -qq "artifacts/${{ needs.build.outputs.algolia_artifact }}" -d algolia-indexes
112+
- name: Update Algolia Index
123113
run: |
124-
env algolia-key='${{env.ALGOLIA_KEY}}' java -jar /opt/builder/help-publication-agent.jar \
125-
update-index \
126-
--application-name '${{env.ALGOLIA_APP_NAME}}' \
127-
--index-name '${{env.ALGOLIA_INDEX_NAME}}' \
128-
--product '${{env.CONFIG_JSON_PRODUCT}}' \
129-
--version '${{env.CONFIG_JSON_VERSION}}' \
130-
--index-directory algolia-indexes/
131-
2>&1 | tee algolia-update-index-log.txt
114+
if [ -z "${{ secrets.ALGOLIA_KEY }}" ]; then
115+
echo "ALGOLIA_KEY secret is not set in GitHub Secrets"
116+
exit 1
117+
else
118+
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
126+
fi

0 commit comments

Comments
 (0)