Add docs.yaml, update test.yaml, vuepress

master
Daniel Lovell 2024-09-30 01:39:12 -07:00
parent 474c322b35
commit 765f3983f3
4 changed files with 107 additions and 24 deletions

79
.github/workflows/docs.yaml vendored Normal file
View File

@ -0,0 +1,79 @@
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

View File

@ -51,26 +51,3 @@ jobs:
with: with:
name: Coverage results for ${{ matrix.testMode }} name: Coverage results for ${{ matrix.testMode }}
path: ${{ steps.tests.outputs.coveragePath }} path: ${{ steps.tests.outputs.coveragePath }}
upload-coverage:
needs: testAllModes
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4
with:
path: coverage-results
- name: Display structure of downloaded files
run: ls -R coverage-results
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: coverage-results
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

18
docs/.vuepress/config.js Normal file
View File

@ -0,0 +1,18 @@
module.exports = {
title: 'Micromissiles Unity Project',
description: 'Documentation for the Micromissiles Unity project',
themeConfig: {
navbar: [
{ text: 'Home', link: '/' },
{ text: 'Keybinds and Controls', link: '/Keybinds_and_Controls.html' },
{ text: 'Simulation Configuration Guide', link: '/Simulation_Config_Guide.html' },
{ text: 'Simulation Logging', link: '/Simulation_Logging.html' },
],
sidebar: 'auto',
},
extendsPageData: (pageData) => {
if (pageData.relativePath === 'README.md') {
pageData.frontmatter.home = true;
}
},
}

9
docs/package.json Normal file
View File

@ -0,0 +1,9 @@
{
"scripts": {
"docs:dev": "vuepress dev .",
"docs:build": "vuepress build ."
},
"devDependencies": {
"vuepress": "^2.0.0-beta.51"
}
}