mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
121 lines
3.7 KiB
YAML
121 lines
3.7 KiB
YAML
name: Documentation
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
paths:
|
|
- 'packages/*/src/**'
|
|
tags:
|
|
- '**'
|
|
workflow_dispatch:
|
|
inputs:
|
|
ref:
|
|
description: 'The branch, tag or SHA to checkout'
|
|
required: true
|
|
ref_type:
|
|
type: choice
|
|
description: 'Branch or tag'
|
|
options:
|
|
- branch
|
|
- tag
|
|
required: true
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
|
|
cancel-in-progress: true
|
|
jobs:
|
|
build:
|
|
name: Build & upload documentation
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
|
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
|
|
if: github.repository_owner == 'discordjs'
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
with:
|
|
ref: ${{ inputs.ref || '' }}
|
|
|
|
- name: Install node.js v16
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 16
|
|
|
|
- name: Install dependencies
|
|
uses: ./packages/actions/src/yarnCache
|
|
|
|
- name: Build dependencies
|
|
run: yarn build
|
|
|
|
- name: Build docs
|
|
run: yarn docs
|
|
|
|
- name: Checkout docs repository
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: 'discordjs/docs'
|
|
token: ${{ secrets.DJS_DOCS }}
|
|
path: 'out'
|
|
|
|
- name: Extract package and semver from tag
|
|
if: ${{ github.ref_type == 'tag' }}
|
|
id: extract-tag
|
|
uses: ./packages/actions/src/formatTag
|
|
with:
|
|
tag: ${{ github.ref_name }}
|
|
|
|
- name: Upload documentation to database
|
|
if: ${{ github.ref_type == 'tag' }}
|
|
env:
|
|
DATABASE_URL: ${{ secrets.DATABASE_URL }}
|
|
uses: ./packages/actions/src/uploadDocumentation
|
|
with:
|
|
package: ${{ steps.extract-tag.outputs.package }}
|
|
version: ${{ steps.extract-tag.outputs.semver }}
|
|
|
|
- name: Move docs to correct directory
|
|
if: ${{ github.ref_type == 'tag' }}
|
|
env:
|
|
PACKAGE: ${{ steps.extract-tag.outputs.package }}
|
|
SEMVER: ${{ steps.extract-tag.outputs.semver }}
|
|
run: |
|
|
mkdir -p "out/${PACKAGE}"
|
|
if [[ "${PACKAGE}" == "discord.js" ]]; then
|
|
mv "packages/${PACKAGE}/docs/docs.json" "out/${PACKAGE}/${SEMVER}.json"
|
|
else
|
|
mv "packages/${PACKAGE}/docs/docs.api.json" "out/${PACKAGE}/${SEMVER}.api.json"
|
|
fi
|
|
|
|
- name: Upload documentation to database
|
|
if: ${{ github.ref_type == 'branch' }}
|
|
env:
|
|
DATABASE_URL: ${{ secrets.DATABASE_URL }}
|
|
uses: ./packages/actions/src/uploadDocumentation
|
|
with:
|
|
package: ${{ steps.extract-tag.outputs.package }}
|
|
|
|
- name: Move docs to correct directory
|
|
if: ${{ github.ref_type == 'branch' }}
|
|
env:
|
|
PACKAGE: ${{ steps.extract-tag.outputs.package }}
|
|
run: |
|
|
declare -a PACKAGES=("brokers" "builders" "collection" "core" "discord.js" "next" "formatters" "proxy" "rest" "util" "voice" "ws")
|
|
for PACKAGE in "${PACKAGES[@]}"; do
|
|
if [[ "${PACKAGE}" == "discord.js" ]]; then
|
|
mkdir -p "out/${PACKAGE}"
|
|
mv "packages/${PACKAGE}/docs/docs.json" "out/${PACKAGE}/${GITHUB_REF_NAME}.json"
|
|
else
|
|
mkdir -p "out/${PACKAGE}"
|
|
mv "packages/${PACKAGE}/docs/docs.api.json" "out/${PACKAGE}/${GITHUB_REF_NAME}.api.json"
|
|
fi
|
|
done
|
|
|
|
- name: Commit and push
|
|
run: |
|
|
cd out
|
|
git config user.name github-actions[bot]
|
|
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
|
git add .
|
|
git commit -m "Docs build for ${GITHUB_REF_TYPE} ${GITHUB_REF_NAME}: ${GITHUB_SHA}" || true
|
|
git push
|