Build and Deploy Documentation #20
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Deploy Documentation | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
env: | |
INSTANCE: 'Writerside/strumenta' | |
DOCKER_VERSION: '243.21565' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
algolia_artifact: ${{ steps.define-ids.outputs.algolia_artifact }} | |
artifact: ${{ steps.define-ids.outputs.artifact }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Define instance id and artifacts | |
id: define-ids | |
run: | | |
INSTANCE=${INSTANCE#*/} | |
INSTANCE_ID_UPPER=$(echo "$INSTANCE" | tr '[:lower:]' '[:upper:]') | |
ARTIFACT="webHelp${INSTANCE_ID_UPPER}2-all.zip" | |
ALGOLIA_ARTIFACT="algolia-indexes-${INSTANCE_ID_UPPER}.zip" | |
# Print the values | |
echo "INSTANCE_ID_UPPER: $INSTANCE_ID_UPPER" | |
echo "ARTIFACT: $ARTIFACT" | |
echo "ALGOLIA_ARTIFACT: $ALGOLIA_ARTIFACT" | |
# Set the environment variables and outputs | |
echo "INSTANCE_ID_UPPER=$INSTANCE_ID_UPPER" >> $GITHUB_ENV | |
echo "ARTIFACT=$ARTIFACT" >> $GITHUB_ENV | |
echo "ALGOLIA_ARTIFACT=$ALGOLIA_ARTIFACT" >> $GITHUB_ENV | |
echo "artifact=$ARTIFACT" >> $GITHUB_OUTPUT | |
echo "algolia_artifact=$ALGOLIA_ARTIFACT" >> $GITHUB_OUTPUT | |
- name: Build docs using Writerside Docker builder | |
uses: JetBrains/writerside-github-action@v4 | |
with: | |
instance: ${{ env.INSTANCE }} | |
docker-version: ${{ env.DOCKER_VERSION }} | |
- name: Save artifact with build results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docs | |
path: | | |
artifacts/${{ steps.define-ids.outputs.artifact }} | |
artifacts/report.json | |
artifacts/${{ steps.define-ids.outputs.algolia_artifact }} | |
retention-days: 7 | |
# - name: Upload build artifact | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: writerside-docs | |
# path: artifacts/ | |
# | |
# - name: Package Built Artifact | |
# run: | | |
# mkdir -p ./package | |
# cp artifacts/webHelpSTRUMENTA2-all.zip ./package/ | |
# cd ./package | |
# echo '{ "name": "writerside-docs", "version": "1.0.0" }' > package.json | |
- name: Deploy to Netlify | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
run: | | |
# Install Netlify CLI | |
npm install -g netlify-cli | |
# Unzip the generated artifact | |
mkdir -p extracted | |
unzip artifacts/${{ env.ARTIFACT }} -d extracted | |
# Deploy extracted content to Netlify | |
netlify deploy --prod --dir extracted | |
- name: Create Release | |
id: create-release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: v${{ github.run_number }} | |
release_name: Documentation Build - ${{ github.run_number }} | |
body: | | |
## Documentation Build | |
This release contains the built documentation artifacts for version ${{ github.run_number }}. | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install GitHub CLI | |
run: sudo apt-get install -y gh | |
- name: Upload Artifact to Release | |
run: | | |
gh release upload v${{ github.run_number }} artifacts/${{ env.ARTIFACT }} --clobber | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload Algolia Artifact to Release | |
run: | | |
gh release upload v${{ github.run_number }} artifacts/${{ env.ALGOLIA_ARTIFACT }} --clobber | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |