From 765f3983f3e295ca894a21c31803ab7b8fe67511 Mon Sep 17 00:00:00 2001 From: Daniel Lovell Date: Mon, 30 Sep 2024 01:39:12 -0700 Subject: [PATCH] Add docs.yaml, update test.yaml, vuepress --- .github/workflows/docs.yaml | 79 +++++++++++++++++++++++++++++++++++++ .github/workflows/test.yaml | 25 +----------- docs/.vuepress/config.js | 18 +++++++++ docs/package.json | 9 +++++ 4 files changed, 107 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/docs.yaml create mode 100644 docs/.vuepress/config.js create mode 100644 docs/package.json diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml new file mode 100644 index 0000000..587cae5 --- /dev/null +++ b/.github/workflows/docs.yaml @@ -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 \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f93a29a..0a12a8c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -50,27 +50,4 @@ jobs: if: always() with: name: Coverage results for ${{ matrix.testMode }} - 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 + path: ${{ steps.tests.outputs.coveragePath }} \ No newline at end of file diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js new file mode 100644 index 0000000..bbeaeac --- /dev/null +++ b/docs/.vuepress/config.js @@ -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; + } + }, +} \ No newline at end of file diff --git a/docs/package.json b/docs/package.json new file mode 100644 index 0000000..240d53b --- /dev/null +++ b/docs/package.json @@ -0,0 +1,9 @@ +{ + "scripts": { + "docs:dev": "vuepress dev .", + "docs:build": "vuepress build ." + }, + "devDependencies": { + "vuepress": "^2.0.0-beta.51" + } +} \ No newline at end of file