forked from momentum-design/momentum-design
-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (108 loc) · 3.77 KB
/
docs.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
name: Deploy Documentation CD
run-name: ${{ github.actor }} is running Deploy Documentation CD
on:
push:
branches:
- main
workflow_dispatch:
env:
BUILD_PATH: '.' # default value when not using subfolders
rid: ${{ github.run_id }}-${{ github.run_number }}
# Setting an environment variable with the value of a configuration variable
ALGOLIA_APP_ID: ${{ vars.ALGOLIA_APP_ID }}
ALGOLIA_INDEX_NAME: ${{ vars.ALGOLIA_INDEX_NAME }}
ALGOLIA_DOC_SEARCH: ${{ vars.ALGOLIA_DOC_SEARCH }}
jobs:
initialize:
name: Initialize
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v3
- name: Setup Node
uses: actions/[email protected]
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: Validate Dependencies
id: validate-dependencies
uses: actions/cache@v3
with:
path: '**/node_modules'
key: node-modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies
if: steps.validate-dependencies.outputs.cache-hit != 'true'
run: yarn
- name: Cache Dependencies
uses: actions/cache@v3
if: steps.validate-dependencies.outputs.cache-hit != 'true'
with:
path: '**/node_modules'
key: node-modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
build:
name: Build
runs-on: ubuntu-latest
needs: initialize
steps:
- name: Checkout Project
uses: actions/checkout@v3
- name: Setup Node
uses: actions/[email protected]
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: Uncache Dependencies
uses: actions/cache@v3
with:
path: '**/node_modules'
key: node-modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Synchronize Packages
run: yarn
- name: Build docs with astro (includes all dependencies + astro)
run: yarn build
working-directory: ${{ env.BUILD_PATH }}
- name: Cache Documentation
uses: actions/cache@v2
with:
path: ${{ env.BUILD_PATH }}/packages/@momentum-design/docs/dist/
key: docs-${{ runner.os }}-${{ env.rid }}
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v2
with:
ref: docs
- name: Clean Documentation
run: |
rm -rf ${{ env.BUILD_PATH }}/docs
- name: Uncache Documentation
uses: actions/cache@v2
with:
path: ${{ env.BUILD_PATH }}/packages/@momentum-design/docs/dist/
key: docs-${{ runner.os }}-${{ env.rid }}
- name: Process Cached Docs
run: cp -avr ${{ env.BUILD_PATH }}/packages/@momentum-design/docs/dist docs/
- name: Generate GitHub Pages Config
run: |
touch docs/.nojekyll
echo "${{ env.rid }}" >> docs/run-id.hash
- name: Deploy Documentation
run: |
git config --local user.email "[email protected]"
git config --local user.name "Momentum Design Automation"
git add ${{ env.BUILD_PATH }}/docs
FILE_COUNT=$(git status -s | wc -l | xargs)
if [[ $FILE_COUNT != '0' ]]
then
echo "Found $FILE_COUNT changed documentation files."
git commit -m "ci(docs): deploy documentation [skip ci] [skip release]"
git push origin docs --force
else
echo "Documentation files have not changed."
echo "Documentation will not be published."
fi