Skip to content

Commit

Permalink
chore: optimize gh actions
Browse files Browse the repository at this point in the history
  • Loading branch information
xooooooooox committed Jan 2, 2025
1 parent 5c2264a commit c644353
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 8 deletions.
123 changes: 123 additions & 0 deletions .github/actions/writerside/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: 'Build and publish Writerside GitHub Pages'

# This workflow can be reused by other workflows
on:
workflow_call:
inputs:
instance:
description: 'Instance identifier (e.g., Writerside/hi)'
required: true
type: string
docker_version:
description: 'Docker version to use'
required: false
default: '243.22562'
branches:
description: 'Branches to trigger on push'
required: false
type: array
default: ['main']
paths:
description: 'Paths to watch for changes'
required: false
type: array
default: ['Writerside/*']

permissions:
contents: read
id-token: write
pages: write

env:
INSTANCE: ${{ inputs.instance }}
DOCKER_VERSION: ${{ inputs.docker_version }}

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 outputs
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 }}
artifact: ${{ steps.define-ids.outputs.artifact }}
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

test:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: docs
path: artifacts

- name: Test documentation
uses: JetBrains/writerside-checker-action@v1
with:
instance: ${{ inputs.instance }}

deploy:
needs: [build, test]
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: docs
path: artifacts

- name: Unzip artifact
run: unzip -O UTF-8 -qq "artifacts/${{ needs.build.outputs.artifact }}" -d dir

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Package and upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: dir

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

21 changes: 13 additions & 8 deletions .github/workflows/publish_writerside_gh_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ name: "[Doc] Publish Writerside Pages"
on:
push:
branches:
- feat/250102-0.8
- main
- feat/241230-0.7
paths: [ 'Writerside/*' ]
workflow_dispatch:

jobs:
pages:
runs-on: ubuntu-latest
steps:
- name: Build Writerside docs using Docker
uses: JetBrains/writerside-github-action@v4
with:
instance: 'Writerside/radp'
invoke-pages-build:
uses: ./.github/actions/writerside
with:
instance: 'Writerside/radp'
docker_version: '243.22562'
branches:
- 'main'
- 'feat/241230-0.7'
paths:
- 'Writerside/*'

0 comments on commit c644353

Please sign in to comment.