-
Notifications
You must be signed in to change notification settings - Fork 1
123 lines (115 loc) · 3.78 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
name: Documentation
on:
push:
branches:
- main
tags:
- '**'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build Documentation
runs-on: ubuntu-latest
if: github.repository_owner == 'josh-development'
outputs:
NAME: ${{ steps.env.outputs.NAME }}
TYPE: ${{ steps.env.outputs.TYPE }}
SHA: ${{ steps.env.outputs.SHA }}
steps:
- name: Checkout Project
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Use Node.js v16
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4
with:
node-version: 16
cache: yarn
registry-url: https://registry.yarnpkg.com/
- name: Install Dependencies
run: yarn --immutable
- name: Build Packages
run: yarn build
- name: Build Documentation
run: yarn docs
- name: Upload Documentation Artifacts
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
with:
name: docs
path: packages/*/docs/api.json
- name: Set Output
id: env
run: |
echo "::set-output name=NAME::${GITHUB_REF_NAME}"
echo "::set-output name=TYPE::${GITHUB_REF_TYPE}"
echo "::set-output name=SHA::${GITHUB_SHA}"
upload:
name: Upload Documentation
needs: build
strategy:
fail-fast: false
matrix:
package:
- auto-ensure
- schema
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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Use Node.js v16
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4
with:
node-version: 16
cache: yarn
registry-url: https://registry.yarnpkg.com/
- name: Install Dependencies
run: yarn --immutable
- name: Download Documentation Artifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3
with:
name: docs
path: docs
- name: Checkout Documentation Project
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
repository: 'josh-development/docs'
token: ${{ secrets.ACCESS_TOKEN }}
path: 'out'
- name: Extract Package and Semver
if: ${{ env.TYPE == 'tag' }}
id: extract-tag
uses: ./scripts/formatTag
with:
tag: ${{ env.NAME }}
- name: Move Documentation
if: ${{ env.TYPE == 'tag' }}
env:
PACKAGE: ${{ steps.extract-tag.outputs.package }}
SEMVER: ${{ steps.extract-tag.outputs.semver }}
run: |
mkdir -p out/middlewares/${PACKAGE}
mv docs/${PACKAGE}/docs/api.json out/middlewares/${PACKAGE}/${SEMVER}.json
- name: Move Documentation
if: ${{ env.TYPE == 'branch' }}
env:
PACKAGE: ${{ matrix.package }}
run: |
mkdir -p out/middlewares/${PACKAGE}
mv docs/${PACKAGE}/docs/api.json out/middlewares/${PACKAGE}/${NAME}.json
- name: Commit & Push
env:
PACKAGE: ${{ matrix.package }}
run: |
cd out
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git config rebase.autostash true
git config pull.rebase true
git add .
git commit -m "docs(${PACKAGE}): build for ${TYPE} ${NAME}: ${SHA}" || true
git pull
git push