-
-
Notifications
You must be signed in to change notification settings - Fork 2
131 lines (117 loc) · 3.77 KB
/
documentation.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# 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