Publish Docs #22
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
# Docs triggered via push will go to prod, while docs triggered via PR will go to preview | |
name: Publish Docs | |
on: | |
workflow_run: | |
workflows: ['Test Modified Plugin'] # Only runs on top level workflows, not reusable workflows called from another run | |
types: | |
- completed | |
jobs: | |
get-docs-packages: | |
runs-on: ubuntu-24.04 | |
outputs: | |
packages: ${{ steps.packages.outputs.result }} | |
steps: | |
- name: Get docs to publish | |
uses: actions/github-script@v7 | |
id: packages | |
with: | |
script: | | |
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: ${{ github.event.workflow_run.id }} | |
}); | |
const versions = artifacts.data.artifacts.filter(artifact => artifact.name.startsWith('docs-build-')); | |
const packages = versions.map(artifact => artifact.name.replace('docs-build-', '')) | |
return packages; | |
publish-docs: | |
needs: get-docs-packages | |
if: ${{ needs.get-docs-packages.outputs.packages != '[]' && needs.get-docs-packages.outputs.packages != '' }} | |
runs-on: ubuntu-24.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
package: ${{fromJson(needs.get-docs-packages.outputs.packages)}} | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: docs-build-${{ matrix.package }} | |
path: docs-build | |
run-id: ${{ github.event.workflow_run.id }} | |
github-token: ${{ github.token }} | |
# Extract the package and version from the artifact directories | |
# Each artifact should only contain 1 package and 1 version as the first 2 directories | |
- name: Extract package and version | |
run: | | |
echo "package=$(ls docs-build)" >> $GITHUB_ENV | |
echo "version=$(ls docs-build/*)" >> $GITHUB_ENV | |
- name: Sync ${{ env.package }}/${{ env.version }} to ${{ github.event.workflow_run.event == 'push' && 'prod' || 'preview' }} | |
uses: deephaven/salmon-sync@v1 | |
with: | |
source: docs-build/${{ env.package }}/${{ env.version }}/ | |
destination: deephaven/deephaven-plugins/${{ env.package }}/${{ env.version }}/ | |
project_number: ${{ secrets.DOCS_GOOGLE_CLOUD_PROJECT_NUMBER}} | |
bucket: ${{ github.event.workflow_run.event == 'push' && vars.DOCS_GOOGLE_CLOUD_BUCKET || vars.DOCS_PREVIEW_BUCKET }} | |
credentials: ${{ secrets.DOCS_GOOGLE_CLOUD_CREDENTIALS }} | |
- name: Comment on PR | |
if: ${{ github.event.workflow_run.event == 'pull_request' }} | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const env = process.env; | |
const path = env.package === 'ui' ? 'core/ui/docs' : 'core/plotly/docs' | |
github.rest.issues.createComment({ | |
issue_number: env.version.replace('pr-', ''), | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `[${env.package} docs preview](https://deephaven-salmon-staging--deephaven-oss.us-central1.hosted.app/${path}/${env.version}) (Available for 14 days)` | |
}); |