Skip to content

Merge pull request #72 from Garlic-Team/renovate/npm-undici-vulnerabi… #41

Merge pull request #72 from Garlic-Team/renovate/npm-undici-vulnerabi…

Merge pull request #72 from Garlic-Team/renovate/npm-undici-vulnerabi… #41

Workflow file for this run

# https://github.com/discordjs/discord.js/blob/main/.github/workflows/documentation.yml
name: Documentation
on:
push:
branches:
- 'master'
tags:
- '**'
jobs:
build:
name: Build documentation
runs-on: ubuntu-latest
if: github.repository_owner == 'Garlic-Team'
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@v2
- name: Install Node v16
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: npm ci
- name: Build docs
run: |
for dir in packages/*
do
cd $dir
npm ci
npm run build:docs
cd ../../
done
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: docs
path: packages/*/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
strategy:
max-parallel: 1
fail-fast: false
matrix:
package:
- 'plugin-blacklist'
- 'plugin-cooldowns'
- 'plugin-language'
- 'plugin-moreevents'
- 'plugin-premium'
- 'plugin-votes'
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@v2
with:
repository: 'garlic-team/docs'
token: ${{ secrets.ACCESS_TOKEN }}
path: 'out'
- name: 'Extract package from tag'
if: env.BRANCH_OR_TAG == 'tag'
id: package-name
uses: frabert/[email protected]
with:
pattern: '(^@.*\\/(?<package>.*)@v?)?(?<semver>\\d+.\\d+.\\d+)-?.*'
string: ${{ env.BRANCH_NAME }}
replace-with: '$<package>'
- name: 'Extract semver from tag'
if: env.BRANCH_OR_TAG == 'tag'
id: semver
uses: frabert/[email protected]
with:
pattern: '(^@.*\\/(?<package>.*)@v?)?(?<semver>\\d+.\\d+.\\d+)-?.*'
string: ${{ env.BRANCH_NAME }}
replace-with: '$<semver>'
- name: Move docs to correct directory
if: env.BRANCH_OR_TAG == 'tag'
env:
PACKAGE: ${{ steps.package-name.outputs.replaced }}
SEMVER: ${{ steps.semver.outputs.replaced }}
run: |
mkdir -p out/gcommands_${PACKAGE}
mv docs/${PACKAGE}/docs/docs.json out/gcommands_${PACKAGE}/${SEMVER}.json
- name: Move docs to correct directory
if: env.BRANCH_OR_TAG == 'branch'
env:
PACKAGE: ${{ matrix.package }}
run: |
mkdir -p out/gcommands_${PACKAGE}
mv docs/${PACKAGE}/docs/docs.json out/gcommands_${PACKAGE}/${BRANCH_NAME}.json
- 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 ${BRANCH_OR_TAG} ${BRANCH_NAME}: ${SHA}" || true
git push