-
Notifications
You must be signed in to change notification settings - Fork 39
57 lines (46 loc) · 1.71 KB
/
update-example-index.yaml
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
# this workflow is used to update the internal/lsp/examples/index.json
# file containing an index of the content available on
# http://docs.styra.com/opa/rego-by-example
name: Update Examples Index
on:
workflow_dispatch:
schedule:
- cron: '0 1 * * *' # Run daily at 1 AM UTC
pull_request:
jobs:
update-examples-index:
name: Update Examples Index
runs-on: ubuntu-22.04
permissions:
contents: write # this workflow updates repo contents
steps:
- name: Check out code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Install xq
run: |
XQ_COMMIT=11673e94cabba145135092bb39200eafd9960cef
curl -sSL "https://raw.githubusercontent.com/sibprogrammer/xq/$XQ_COMMIT/scripts/install.sh" \
| sudo bash
- uses: open-policy-agent/setup-opa@34a30e8a924d1b03ce2cf7abe97250bbb1f332b5 # v2.2.0
with:
version: edge
static: true
- name: Fetch sitemap and convert to JSON
run: |
set -o pipefail
TEMP_DIR=$(mktemp -d)
curl -L https://docs.styra.com/sitemap.xml -o "$TEMP_DIR/sitemap.xml"
xq . "$TEMP_DIR/sitemap.xml" > "$TEMP_DIR/output.json"
echo "catting JSON"
cat "$TEMP_DIR/output.json"
cat "$TEMP_DIR/output.json" | \
opa eval 'data.process.symbols' \
-d build/workflows/update-example-index/process.rego \
--format=raw \
--stdin-input \
| jq \
| tee internal/lsp/examples/index.json
# - name: Commit and push changes
# uses: stefanzweifel/git-auto-commit-action@v4
# with:
# commit_message: Update Imported Docs