-
Notifications
You must be signed in to change notification settings - Fork 45
110 lines (107 loc) · 4 KB
/
push-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
name: Deploy documentation
on:
push:
merge_group:
pull_request_target:
# this is for forked pull requests - we can't pass down secrets; this allows us to pass down secrets
# to build the cloudflare pages action
types:
- opened
- labeled
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Publish to Cloudflare Pages
if: ${{
github.repository == 'kurtosis-tech/kurtosis' &&
(
github.event_name == 'push' ||
github.event_name == 'merge_group' ||
(
github.event_name == 'pull_request_target' &&
github.event.action == 'labeled' &&
github.event.pull_request.head.repo.fork == true &&
contains(github.event.label.name, 'request-cf-deploy')
))
}}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Enforce to use yarn
run: |
# We had a bug where we were using both Yarn and NPM to maintain Docusaurus, which
# meant separate and conflicting lockfiles
# Only Yarn should be used
if [ -f docs/package-lock.json ]; then
exit 1
fi
- name: Docs have changed
run: |
echo "DOCS_CHANGED=$(git --no-pager diff --exit-code origin/main...HEAD -- ':docs' > /dev/null; echo $?)" >> $GITHUB_OUTPUT
id: docs-diff
- name: Append changelog
run: cat CHANGELOG.md >> docs/docs/changelog.md
if: github.ref == 'refs/heads/main' || steps.docs-diff.outputs.DOCS_CHANGED != 0
- name: Yarn Install
run: yarn --cwd ./docs --frozen-lockfile install
if: github.ref == 'refs/heads/main' || steps.docs-diff.outputs.DOCS_CHANGED != 0
- name: Yarn Build
run: yarn --cwd ./docs build
if: github.ref == 'refs/heads/main' || steps.docs-diff.outputs.DOCS_CHANGED != 0
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
if: github.ref == 'refs/heads/main' || steps.docs-diff.outputs.DOCS_CHANGED != 0
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }}
directory: docs/build/
# as we publish on tag we want to tell CF that the branch is still main so that it can deploy to production
branch: ${GITHUB_REF##*/}
reindex-website-main:
runs-on: ubuntu-latest
name: Update website search index via Algolia Crawler
if: ${{
github.event_name == 'push' &&
github.ref == 'refs/heads/main'
}}
steps:
- uses: fjogeleit/http-request-action@v1
with:
url: "https://crawler.algolia.com/api/1/crawlers/${{ secrets.ALGOLIA_CRAWLER_ID }}/reindex"
method: "POST"
username: ${{ secrets.ALGOLIA_CRAWLER_USER_ID }}
password: ${{ secrets.ALGOLIA_CRAWLER_API_KEY }}
customHeaders: '{"Content-Type": "application/json"}'
needs: publish
# check-index:
# runs-on: ubuntu-latest
# name: Checks that the latest index is still working
# if: ${{
# github.event_name == 'push' &&
# github.ref == 'refs/heads/main'
# }}
# steps:
# - uses: fjogeleit/http-request-action@v1
# id: search
# with:
# url: "https://NTSX40VZB8-dsn.algolia.net/1/indexes/kurtosis/query"
# method: 'POST'
# customHeaders: '{"X-Algolia-API-Key": "4269c726c2fea4e6cddfeb9a21cd3d4e", "X-Algolia-Application-Id": "NTSX40VZB8"}'
# data: '{ "params": "query=add_service&hitsPerPage=2&getRankingInfo=1" }'
# - name: Show Response
# run: |
# #!/bin/bash
# set -eou pipefail
# if (( ${{ fromJson(steps.search.outputs.response).nbHits }} > 100 )); then
# echo "Results are greater than 100"
# else
# echo "Results are not greater than 100"
# exit 1
# fi
# needs: reindex-website-main