forked from momentum-design/momentum-design
-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (102 loc) · 3.67 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
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
PUBLIC_ALGOLIA_APP_ID: ${{ secrets.PUBLIC_ALGOLIA_APP_ID }}
PUBLIC_ALGOLIA_INDEX_NAME: ${{ secrets.PUBLIC_ALGOLIA_INDEX_NAME }}
PUBLIC_ALGOLIA_DOC_SEARCH: ${{ secrets.PUBLIC_ALGOLIA_DOC_SEARCH }}
jobs:
initialize:
name: Initialize
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: Validate Dependencies
id: validate-dependencies
uses: actions/cache@v4
with:
path: '**/node_modules'
key: node-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies
run: yarn
- name: Cache Dependencies
uses: actions/cache@v4
if: steps.validate-dependencies.outputs.cache-hit != 'true'
with:
path: '**/node_modules'
key: node-modules-${{ hashFiles('**/yarn.lock') }}
build:
name: Build
runs-on: ubuntu-latest
needs: initialize
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: Uncache Dependencies
uses: actions/cache@v4
with:
path: '**/node_modules'
key: node-modules-${{ hashFiles('**/yarn.lock') }}
- name: Synchronize Packages
run: yarn
- name: Build docs with astro (includes all dependencies + astro)
run: PUBLIC_ALGOLIA_APP_ID=${{ env.PUBLIC_ALGOLIA_APP_ID }} PUBLIC_ALGOLIA_INDEX_NAME=${{ env.PUBLIC_ALGOLIA_INDEX_NAME }} PUBLIC_ALGOLIA_DOC_SEARCH=${{ env.PUBLIC_ALGOLIA_DOC_SEARCH }} yarn build
working-directory: ${{ env.BUILD_PATH }}
- name: Cache Documentation
uses: actions/cache@v4
with:
path: ${{ env.BUILD_PATH }}/packages/documentation/dist/
key: docs-${{ env.rid }}
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: docs
- name: Clean Documentation
run: |
rm -rf ${{ env.BUILD_PATH }}/docs
- name: Uncache Documentation
uses: actions/cache@v4
with:
path: ${{ env.BUILD_PATH }}/packages/documentation/dist/
key: docs-${{ env.rid }}
- name: Process Cached Docs
run: cp -avr ${{ env.BUILD_PATH }}/packages/documentation/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 "automation@momentum.design"
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