micromissiles-unity/.github/workflows/docs.yaml

79 lines
2.3 KiB
YAML
Raw Normal View History

name: Deploy Documentation
on:
workflow_run:
workflows: ["Test"]
types:
- completed
permissions:
contents: read
pages: write
id-token: write
jobs:
build-deploy:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install dependencies
run: npm install
working-directory: './docs'
- name: Download coverage artifacts
uses: actions/github-script@v6
with:
script: |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
var matchArtifacts = artifacts.data.artifacts.filter((artifact) => {
return artifact.name.startsWith("Coverage results for")
});
for (const artifact of matchArtifacts) {
var download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync(`${{github.workspace}}/${artifact.name}.zip`, Buffer.from(download.data));
}
- name: Extract coverage reports
run: |
mkdir -p ./docs/.vuepress/public/coverage
for file in Coverage*.zip; do
mode=$(echo $file | sed 's/Coverage results for \(.*\)\.zip/\1/')
unzip -o "$file" -d "./docs/.vuepress/public/coverage/$mode"
done
- name: Build documentation
run: npm run docs:build
working-directory: './docs'
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: 'docs/.vuepress/dist'
deploy:
needs: build-deploy
runs-on: ubuntu-latest
environment:
name: github-pages
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2