-
Notifications
You must be signed in to change notification settings - Fork 9
201 lines (175 loc) · 7.17 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
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
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_checker.js
- name: Prepare data files for GPTs
run: node utils/js/create_data_for_gpts.js
- name: Set 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
- 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@v5
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 atomicdex methods table"
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 AtomicDEX API Methods Table"
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, AtomicDEX API Methods Table auto-generated
labels: |
autogenerated
reviewers: smk762, gcharang
draft: false
outputs:
NO_DIFF: ${{ steps.diff_check.outputs.NO_DIFF}}
LINT_BRANCH: ${{ steps.vars.outputs.lint_branch_name}}
BRANCH: ${{ steps.vars.outputs.BRANCH_NAME}}
web_build_and_preview:
needs: update_lint_get_data
name: Build and deploy
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Extract branch name of mdx repo
shell: bash
run: |
BRANCH_NAME="${{ github.head_ref || github.ref }}"
BRANCH_NAME=${BRANCH_NAME#refs/heads/} # remove the refs/heads/ prefix
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT
id: get_branch
- name: Shortify commit sha
shell: bash
run: |
echo "sha_short=$(echo ${GITHUB_SHA::7})" >> $GITHUB_OUTPUT
id: shortify_commit
- name: Checkout code
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.DOCS_UI_SSH_PRIVATE_KEY }}
repository: KomodoPlatform/website-komodo-docs
ref: main
submodules: recursive
fetch-depth: 0
- name: Get updated content (without diff)
if: needs.update_lint_get_data.outputs.NO_DIFF == 'true'
run: |
cd utils
./update_mdx_branch.sh ${{ needs.update_lint_get_data.outputs.BRANCH }}
cd ..
./update-content.sh
- name: Get updated content (with diff)
if: needs.update_lint_get_data.outputs.NO_DIFF == 'false'
run: |
cd utils
./update_mdx_branch.sh ${{ needs.update_lint_get_data.outputs.LINT_BRANCH }}
cd ..
./update-content.sh
- uses: actions/setup-node@v3
with:
node-version: "16.14"
cache: yarn
- 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: Install build deps
run: yarn install
- name: Build
run: yarn export:cfp
- name: Add no-index headers before pubishing to cloudflare
run: |
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: ./out
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
wranglerVersion: "3"
branch: ${{ steps.get_branch.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.shortify_commit.outputs.sha_short }}, available on cloudflare at: ${{ steps.cf_publish.outputs.url }}/en/docs/"
})