Add workflow to build technical documentation using full website #22
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
name: Build technical documentation | |
on: | |
pull_request: | |
paths: ["docs/sources/**"] | |
workflow_dispatch: | |
jobs: | |
main: | |
runs-on: ubuntu-latest | |
container: | |
image: grafana/docs-base:latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Generate GitHub token | |
id: generate-token | |
uses: tibdex/github-app-token@v1 | |
with: | |
app_id: ${{ secrets.GRAFANA_DELIVERY_BOT_APP_ID }} | |
private_key: ${{ secrets.GRAFANA_DELIVERY_BOT_APP_PEM }} | |
- name: Sparse clone website repository | |
run: | | |
git clone --filter=blob:none --no-checkout --sparse --depth 1 https://x-access-token:${TOKEN}@github.com/grafana/website.git website | |
git -C website sparse-checkout set content/docs | |
git -C website checkout master | |
env: | |
TOKEN: ${{ steps.generate-token.outputs.token }} | |
- name: Checkout Actions library | |
uses: actions/checkout@v3 | |
with: | |
repository: grafana/grafana-github-actions | |
path: ./actions | |
- name: Install Actions from library | |
run: npm install --production --prefix ./actions | |
- name: Determine technical documentation version | |
uses: ./actions/docs-target | |
id: target | |
with: | |
ref_name: ${{ github.base_ref }} | |
- name: Build website | |
# Note that busybox `ln` does not have the `-F` option. | |
run: | | |
rm -rf /hugo/content/docs | |
ln -sn "$(pwd)/website/content/docs" /hugo/content/docs | |
rm -rf "/hugo/content/docs/grafana/${TARGET}" | |
ln -sn "$(pwd)/docs/sources" "/hugo/content/docs/grafana/${TARGET}" | |
cd /hugo | |
unset WEBSITE_SKIP_MOUNTS | |
make hugo HUGO_ENV=docs | grep docs/grafana/ | |
env: | |
TARGET: ${{ steps.target.outputs.target }} | |
- name: Run doc-validator tool | |
# Only run doc-validator on specific directories. | |
run: > | |
doc-validator | |
"--include=^/hugo/content/docs/${TARGET}/(?:alerting|fundamentals|getting-started|introduction|setup-grafana|upgrade-guide|whatsnew/whats-new-in-v(?:9|10))/.+\.md$" | |
'--skip-checks=^(?:image.+|canonical-does-not-match-pretty-URL)$' | |
"/hugo/content/docs/${TARGET}" | |
/docs/grafana/latest | |
| reviewdog | |
-f=rdjsonl | |
--fail-on-error | |
--filter-mode=nofilter | |
--name=doc-validator | |
--reporter=github-pr-review | |
env: | |
REVIEWDOG_GITHUB_API_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
TARGET: ${{ steps.target.outputs.target }} |