Skip to content

Commit 4f9c427

Browse files
saihajDimitri POSTOLOV
andauthored
ci: website integrity checks (#288)
* ci: website integrity checks * Apply suggestions from code review Co-authored-by: Dimitri POSTOLOV <[email protected]> * fix script --------- Co-authored-by: Dimitri POSTOLOV <[email protected]>
1 parent f74266d commit 4f9c427

File tree

8 files changed

+464
-1
lines changed

8 files changed

+464
-1
lines changed

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ALGOLIA_API_KEY=
2+
ALGOLIA_APP_ID=
3+
NPM_TOKEN=
4+
SITE_URL=https://thegraph.com/docs
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Website Integrity
2+
on:
3+
pull_request:
4+
paths:
5+
- 'pages/**'
6+
branches:
7+
- main
8+
jobs:
9+
website-check:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
- name: Fetch
15+
run: git fetch origin main
16+
17+
- name: Setup env
18+
uses: the-guild-org/shared-config/setup@main
19+
with:
20+
nodeVersion: 18
21+
packageManager: yarn
22+
23+
- name: Build Site
24+
run: yarn build
25+
26+
- name: Compare
27+
run: git diff origin/${{ github.base_ref }}.. -- route-lockfile.txt
28+
29+
- name: Diff to file
30+
if: always()
31+
id: diff_result
32+
run: |
33+
echo "result<<EOF" >> $GITHUB_OUTPUT
34+
echo "$(git diff origin/${{ github.base_ref }}.. -- route-lockfile.txt)" >> $GITHUB_OUTPUT
35+
echo EOF >> $GITHUB_OUTPUT
36+
37+
- name: Publish a message
38+
if: always() && contains(steps.diff_result.outputs.result, 'diff')
39+
uses: marocchino/sticky-pull-request-comment@v2
40+
with:
41+
message: |
42+
```diff
43+
${{ steps.diff_result.outputs.result }}
44+
```

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ yarn-error.log*
3838
*.tsbuildinfo
3939

4040
.idea/
41+
42+
public/sitemap*.xml

next-sitemap.config.cjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/** @type {import('next-sitemap').IConfig} */
2+
module.exports = {
3+
siteUrl: process.env.SITE_URL || 'https://thegraph.com/docs/',
4+
generateIndexSitemap: false,
5+
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"scripts": {
66
"dev": "next dev",
77
"build": "rm -rf .next && next build",
8+
"postbuild": "next-sitemap --config next-sitemap.config.cjs && node scripts/sitemap-ci.mjs",
89
"start": "next start",
910
"export": "rm -rf out && next export -o out/docs",
1011
"lint": "eslint . --ext .js,.jsx,.ts,.tsx,.mjs && yarn prettier:check && yarn typecheck",
@@ -33,6 +34,7 @@
3334
"lodash": "^4.17.21",
3435
"next": "^12.3.4",
3536
"next-seo": "^5.15.0",
37+
"next-sitemap": "^3.1.52",
3638
"prism-react-renderer": "^1.3.5",
3739
"react": "^17.0.2",
3840
"react-dom": "^17.0.2",
@@ -54,6 +56,7 @@
5456
"acorn": "^8.8.2",
5557
"acorn-jsx": "^5.3.2",
5658
"eslint": "^8.34.0",
59+
"fast-xml-parser": "^4.1.2",
5760
"husky": "^8.0.3",
5861
"lint-staged": "^13.1.1",
5962
"path": "^0.12.7",

0 commit comments

Comments
 (0)