-
Notifications
You must be signed in to change notification settings - Fork 156
116 lines (100 loc) · 3.28 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
name: Docs
on:
push:
branches:
- master
paths:
- "docs/src/openapi-v1.yaml"
pull_request:
branches:
- master
paths:
- "docs/src/openapi-v1.yaml"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build-docs:
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
- name: Checkout files
uses: actions/checkout@v4
- name: Install Node v18
uses: actions/setup-node@v4
with:
node-version: "18.14"
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install JS dependencies
run: yarn install
- name: Build Docs
run: yarn build:docs
- name: Create artifacts
if: github.ref == 'refs/heads/master'
run: |
mkdir -p artifacts
mv docs/dist artifacts/
ls -la artifacts
- name: Upload docs
if: github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v4
with:
name: doc-${{ github.sha }}
path: ./artifacts/
publish-docs:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
environment: master_n_tags
needs: [build-docs]
steps:
- uses: actions/checkout@v4
with:
ref: gh-pages
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.GH_APP_SAS_APP_ID }}
private-key: ${{ secrets.GH_APP_SAS_APP_KEY }}
- name: Download docs
uses: actions/download-artifact@v4
with:
name: doc-${{ github.sha }}
path: tmp/
- name: Check files
run: |
ls -la
rm -rf dist/
mv tmp/dist/ dist/
rm -rf tmp/
git status
- name: Push changes to gh-pages
env:
TOKEN: ${{ steps.app-token.outputs.token }}
APP_NAME: "paritytech-upd-ghpages-sas"
REF_NAME: ${{ github.head_ref || github.ref_name }}
Green: "\e[32m"
NC: "\e[0m"
run: |
echo "${Green}Git add${NC}"
git add dist/
echo "${Green}git status | wc -l${NC}"
git status | wc -l
echo "${Green}Add new remote with gh app token${NC}"
git remote set-url origin $(git config remote.origin.url | sed "s/github.com/${APP_NAME}:${TOKEN}@github.com/g")
echo "${Green}Remove http section that causes issues with gh app auth token${NC}"
sed -i.bak '/\[http/d' ./.git/config
sed -i.bak '/extraheader/d' ./.git/config
echo "${Green}Git push${NC}"
git config user.email "[email protected]"
git config user.name "${APP_NAME}"
git commit -m "___Updated docs" || echo "___Nothing to commit___"
git push origin gh-pages --force