lsp: Auto update examples index #8
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" | |
cat "$TEMP_DIR/output.json" | \ | |
opa eval 'data.process.symbols' \ | |
-d build/workflows/update-example-index/process.rego \ | |
--format=raw \ | |
--stdin-input \ | |
| tee internal/lsp/examples/index.json | |
# - name: Commit and push changes | |
# uses: stefanzweifel/git-auto-commit-action@v4 | |
# with: | |
# commit_message: Update Imported Docs |