ci(delivery): add github token #111
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Documentation | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
inputs: | |
ref: | |
description: 'The branch, tag or SHA to checkout' | |
required: true | |
jobs: | |
build: | |
name: Build Documentation | |
runs-on: ubuntu-latest | |
if: github.repository_owner == 'RealShadowNova' | |
outputs: | |
NAME: ${{ steps.env.outputs.NAME }} | |
TYPE: ${{ steps.env.outputs.TYPE }} | |
SHA: ${{ steps.env.outputs.SHA }} | |
steps: | |
- name: Checkout Project | |
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 | |
- name: Use Node.js v20 | |
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4 | |
with: | |
node-version: 20 | |
cache: yarn | |
registry-url: https://registry.npmjs.org/ | |
- name: Install Dependencies | |
run: yarn --immutable | |
- name: Build Documentation | |
run: yarn docs | |
- name: Upload Documentation Artifacts | |
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4 | |
with: | |
name: docs | |
path: docs/api.json | |
- name: Set Output | |
id: env | |
run: | | |
echo "NAME=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT | |
echo "TYPE=${GITHUB_REF_TYPE}" >> $GITHUB_OUTPUT | |
echo "SHA=${GITHUB_SHA}" >> $GITHUB_OUTPUT | |
upload: | |
name: Upload Documentation | |
needs: build | |
runs-on: ubuntu-latest | |
env: | |
NAME: ${{ needs.build.outputs.NAME }} | |
TYPE: ${{ needs.build.outputs.TYPE }} | |
SHA: ${{ needs.build.outputs.SHA }} | |
steps: | |
- name: Checkout Project | |
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 | |
- name: Use Node.js v20 | |
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4 | |
with: | |
node-version: 20 | |
cache: yarn | |
registry-url: https://registry.npmjs.org/ | |
- name: Install Dependencies | |
run: yarn --immutable | |
- name: Download Documentation Artifacts | |
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4 | |
with: | |
name: docs | |
path: docs | |
- name: Checkout Documentation Project | |
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 | |
with: | |
repository: 'RealShadowNova/docs' | |
token: ${{ secrets.NOVA_TOKEN }} | |
path: 'out' | |
- name: Move Documentation | |
if: ${{ env.TYPE == 'tag' }} | |
env: | |
SEMVER: ${{ env.NAME }} | |
run: | | |
mkdir -p out/docs/better-serialize | |
mv docs/api.json out/docs/better-serialize/${SEMVER}.json | |
- name: Move Documentation | |
if: ${{ env.TYPE == 'branch' }} | |
run: | | |
mkdir -p out/docs/better-serialize | |
mv docs/api.json out/docs/better-serialize/${NAME}.json | |
- name: Commit & 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(better-serialize): build for ${TYPE} ${NAME}: ${SHA}" || true | |
git push |