Skip to content

Build and Deploy Writerside + CodeLabs #21

Build and Deploy Writerside + CodeLabs

Build and Deploy Writerside + CodeLabs #21

Workflow file for this run

name: Build and Deploy Writerside + CodeLabs
on:
push:
branches: [ "dev" ]
workflow_dispatch:
permissions:
id-token: write
pages: write
env:
INSTANCE: 'Writerside/modo-docs'
ARTIFACT: 'webHelpMODO-DOCS2-all.zip'
DOCKER_VERSION: '241.15989'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# Install claat tool
- name: Install claat tool
run: go install github.com/googlecodelabs/tools/claat@latest
env:
GOPATH: ${{ runner.temp }}/go
# Ensure claat is in PATH
- name: Add claat to PATH
run: echo "${{ runner.temp }}/go/bin" >> $GITHUB_PATH
# Step to Generate CodeLab HTML Files
- name: Generate CodeLabs content
run: |
mkdir -p codelabs-generated
claat export -o codelabs-generated codelabs/workshop/workshop-codelab.md || exit 1
# Verify that CodeLabs files were generated
- name: List generated CodeLabs files
run: ls -la codelabs-generated
# Writerside build step
- name: Build docs using Writerside Docker builder
uses: JetBrains/writerside-github-action@v4
with:
instance: ${{ env.INSTANCE }}
artifact: ${{ env.ARTIFACT }}
docker-version: ${{ env.DOCKER_VERSION }}
# Unzip the Writerside artifact
- name: Unzip Writerside artifact
run: |
mkdir -p dir
unzip -O UTF-8 -qq artifacts/${{ env.ARTIFACT }} -d dir
# Verify Writerside files were unzipped correctly
- name: Verify unzipped Writerside content
run: ls -la dir
# Combine CodeLabs and Writerside output
- name: Copy CodeLabs to Writerside output
run: |
if [ -d "codelabs-generated" ] && [ "$(ls -A codelabs-generated)" ]; then
cp -R codelabs-generated/* dir/
else
echo "No CodeLabs content generated."
exit 1
fi
# Verify CodeLabs content was copied into Writerside output
- name: Verify combined content in Writerside output
run: ls -la dir
# Zip the combined Writerside + CodeLabs content
- name: Zip combined content
run: zip -r combined-docs.zip dir
# Save the ZIP artifact with combined Writerside + CodeLabs content
- name: Save combined artifact with Writerside and CodeLabs
uses: actions/upload-artifact@v4
with:
name: docs
path: combined-docs.zip
retention-days: 7
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# Requires build job results
needs: build
runs-on: ubuntu-latest
steps:
# Download the artifact (ZIP file)
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: docs
# Unzip the artifact
- name: Unzip artifact
run: unzip combined-docs.zip -d dir
# Verify the unzipped content
- name: Verify unzipped content
run: ls -la dir
# Set up for GitHub Pages deployment
- name: Setup Pages
uses: actions/[email protected]
# Upload the CONTENTS of the 'dir' folder to GitHub Pages ROOT
- name: Upload to GitHub Pages
uses: actions/[email protected]
with:
path: dir/** # This uploads all the contents of 'dir/' to the root
- name: Deploy to GitHub Pages
id: deployment
uses: actions/[email protected]