-
Notifications
You must be signed in to change notification settings - Fork 9
217 lines (190 loc) · 9.42 KB
/
get_data_lint_files_deploy.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: Get file and author data, validate and update internal links, deploy
on:
push:
branches: ["dev"]
pull_request:
types: [opened, edited, synchronize, reopened, ready_for_review]
jobs:
pre_job:
# continue-on-error: true # Uncomment once integration is finished
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
# All of these options are optional, so you can remove them if you are happy with the defaults
concurrent_skipping: "never"
skip_after_successful_duplicate: "true"
do_not_skip: '["pull_request"]'
update_lint_get_data:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true' && startsWith(github.head_ref, 'lint-fix-patches') == false && github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: "16"
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: npm-
- name: Generate configs
shell: bash
run: ${GITHUB_WORKSPACE}/utils/gen_api_methods_table.py
- name: Install dependencies
shell: bash
run: cd utils/js && npm ci
- name: Get file and Author data
if: github.base_ref == 'main' || github.ref == 'refs/heads/main'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node utils/js/get_file_author_data.js
- name: Validate and Update links
run: node utils/js/validate_update_internal_links_userpass.js
- name: Check presence of file and dirs
run: node utils/js/file_presence_structure_checker.js
- name: Verify h1 is present in every file
run: node utils/js/h1_presence_format_checker.js
- name: Prepare data files for GPTs
if: github.base_ref == 'main' || github.ref == 'refs/heads/main'
run: node utils/js/create_data_for_gpts.js
- name: Ensure change logs are updated
if: github.base_ref == 'main' || github.ref == 'refs/heads/main'
run: node utils/js/ensure_changelog_update.js
- name: Generate Search Index
if: github.base_ref == 'main' || github.ref == 'refs/heads/main'
run: node utils/js/create_search_index.js
- name: Set branch name, commit_sha, lint-fix branch name
id: vars
shell: bash
run: |
BRANCH_NAME="${{ github.head_ref || github.ref }}"
BRANCH_NAME=${BRANCH_NAME#refs/heads/}
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_OUTPUT
lint_branch_name="lint-fix-patches/${BRANCH_NAME}"
echo "lint_branch_name=$lint_branch_name" >> $GITHUB_OUTPUT
echo "sha_short=$(echo ${GITHUB_SHA::7})" >> $GITHUB_OUTPUT
- name: Checkout code
uses: actions/checkout@v3
with:
path: website-komodoplatform.com
ssh-key: ${{ secrets.DOCS_UI_SSH_PRIVATE_KEY }}
repository: KomodoPlatform/website-komodoplatform.com
ref: dev
submodules: recursive
fetch-depth: 0
- uses: actions/setup-node@v3
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "true"
with:
node-version: "18.20.4"
cache: yarn
cache-dependency-path: "**/yarn.lock"
- name: Restore cache
uses: actions/cache@v3
with:
path: |
.next/cache
# Generate a new cache whenever packages or source files change.
key:
nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
- name: Get updated content, Install deps, build, Add no-index headers before pubishing to cloudflare
run: |
pwd
echo $GITHUB_WORKSPACE
ls $GITHUB_WORKSPACE
cd $GITHUB_WORKSPACE/website-komodoplatform.com/utils
./update_mdx_branch.sh ${{ steps.vars.outputs.BRANCH_NAME }}
cd ..
export CFP=yes
yarn install
./update-content.sh
rsync -avh --delete $GITHUB_WORKSPACE/utils/_fileData.json $GITHUB_WORKSPACE/website-komodoplatform.com/src/data/docs/_fileData.json
rsync -avh --delete $GITHUB_WORKSPACE/utils/_searchIndex.json $GITHUB_WORKSPACE/website-komodoplatform.com/src/data/docs/searchIndex.json
yarn export
echo -e "https://:project.pages.dev/*\n X-Robots-Tag: noindex" > ./out/_headers
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
id: cf_publish
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
projectName: komodo-docs
directory: ./website-komodoplatform.com/out
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
wranglerVersion: "3"
branch: ${{ steps.vars.outputs.BRANCH_NAME }}
- name: Post CF preview url
uses: actions/github-script@v6
if: github.event_name == 'pull_request'
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Preview for merge commit: ${{ steps.vars.outputs.sha_short }}, available on cloudflare at: ${{ steps.cf_publish.outputs.url }}/en/docs/"
})
- name: Update package repos, Install libgconf-2-4, wget, Add Google Chrome repository, Install Google Chrome Stable, Clean up
if: github.base_ref == 'main' || github.ref == 'refs/heads/main'
run: |
sudo apt-get update
sudo apt-get install -yq libgconf-2-4
sudo apt-get install -y wget --no-install-recommends
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google.list
sudo apt-get update
sudo apt-get install -y google-chrome-stable --no-install-recommends
sudo rm -rf /var/lib/apt/lists/*
# Setting environment variable for Puppeteer and generating preview images
- name: Set PUPPETEER_SKIP_CHROMIUM_DOWNLOAD and CF_PUBLISH_URL
if: github.base_ref == 'main' || github.ref == 'refs/heads/main'
run: |
echo "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true" >> $GITHUB_ENV
echo "CF_PUBLISH_URL=${{ steps.cf_publish.outputs.url }}" >> $GITHUB_ENV
- name: Generate Preview Images
if: github.base_ref == 'main' || github.ref == 'refs/heads/main'
run: |
cd $GITHUB_WORKSPACE/website-komodoplatform.com/
git status
yarn gen:previewImgs
- name: Update mdx repo with preview images
if: github.base_ref == 'main' || github.ref == 'refs/heads/main'
run: mkdir -p $GITHUB_WORKSPACE/preview-images/optimized/ && mkdir -p $GITHUB_WORKSPACE/preview-images/original/ && rsync -avh --delete $GITHUB_WORKSPACE/website-komodoplatform.com/preview-images-original/ $GITHUB_WORKSPACE/preview-images/original/ && rsync -avh --delete $GITHUB_WORKSPACE/website-komodoplatform.com/public/preview-images/ $GITHUB_WORKSPACE/preview-images/optimized/ && rsync -avh --delete $GITHUB_WORKSPACE/website-komodoplatform.com/src/data/docs/previewImgTimeStamps.json $GITHUB_WORKSPACE/preview-images/previewImgTimeStamps.json
- name: Delete repo checked out UI repo
run: rm -rf $GITHUB_WORKSPACE/website-komodoplatform.com
# - name: Check if diff exists
# id: diff_check
# run: |
# if git diff --quiet; then
# echo "NO_DIFF=true" >> $GITHUB_OUTPUT
# else
# echo "NO_DIFF=false" >> $GITHUB_OUTPUT
# fi
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "[Bot] File and author data updated, validated and updated internal links, formatted md content, checked presence of file and dirs based on sidebar, checked presence of h1 in every file, update Komodo DeFi Framework methods table, adds/updates preview images when base is main"
committer: GitHub <[email protected]>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
branch: ${{ steps.vars.outputs.lint_branch_name}}
delete-branch: true
title: "[BOT] PR to ${{ steps.vars.outputs.branch_name}}. Lints file structure, file contents, gets author data, Updates Komodo DeFi Framework Methods Table, adds/updates preview images"
body: |
- File and author data updated, validated and updated internal links, formatted md content, checked presence of file and dirs based on sidebar, checked presence of h1 in every file, Komodo DeFi Framework Methods Table auto-generated
labels: |
autogenerated
reviewers: smk762, gcharang
draft: false