Skip to content

chore: add workflow for generating docs source files #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Documentation
on:
push:
branches:
- 'main'
- 'stable'
tags:
- '**'
jobs:
build:
name: Build documentation
runs-on: ubuntu-latest
if: github.repository_owner == 'twitterjs'
outputs:
BRANCH_NAME: ${{ steps.env.outputs.BRANCH_NAME }}
BRANCH_OR_TAG: ${{ steps.env.outputs.BRANCH_OR_TAG }}
SHA: ${{ steps.env.outputs.SHA }}
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install node.js v16
uses: actions/setup-node@v2
with:
node-version: 16

- name: Install dependencies
run: npm ci

- name: Build docs
run: npm run doc

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: docs
path: docs/docs.json

- name: Set outputs for upload job
id: env
run: |
echo "::set-output name=BRANCH_NAME::${GITHUB_REF_NAME}"
echo "::set-output name=BRANCH_OR_TAG::${GITHUB_REF_TYPE}"
echo "::set-output name=SHA::${GITHUB_SHA}"
upload:
name: Upload documentation
needs: build
runs-on: ubuntu-latest
env:
BRANCH_NAME: ${{ needs.build.outputs.BRANCH_NAME }}
BRANCH_OR_TAG: ${{ needs.build.outputs.BRANCH_OR_TAG }}
SHA: ${{ needs.build.outputs.SHA }}
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: docs
path: docs

- name: Checkout docs repository
uses: actions/checkout@v3
with:
repository: 'twitterjs/docs'
path: 'out'

- name: Move docs to correct directory
run: |
mkdir -p out/twitter.js
mv docs/docs.json out/twitter.js/${BRANCH_NAME}.json

- name: Commit and push
run: |
cd out
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "Docs build for ${BRANCH_OR_TAG} ${BRANCH_NAME}: ${SHA}" || true
git push
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"build": "tsc -p tsconfig.json && tsc -p tsconfig.declaration.json",
"build:dev": "tsc -w",
"doc": "typedoc",
"doc": "typedoc --json docs/typedoc-out.json src/index.ts && node scripts/DocsBuilder.mjs",
"test": "vitest",
"prepare": "husky install",
"lint:check": "eslint . --ext .js,.ts",
Expand All @@ -28,6 +28,7 @@
"devDependencies": {
"@commitlint/cli": "^16.2.1",
"@commitlint/config-angular": "^16.2.1",
"@discordjs/ts-docgen": "^0.3.4",
"@types/node": "^17.0.21",
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.13.0",
Expand Down
6 changes: 6 additions & 0 deletions scripts/DocsBuilder.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { runGenerator } from '@discordjs/ts-docgen';

runGenerator({
existingOutput: 'docs/typedoc-out.json',
output: 'docs/docs.json',
});
7 changes: 0 additions & 7 deletions typedoc.json

This file was deleted.