Skip to content

Add workflow to build technical documentation using full website #27

Add workflow to build technical documentation using full website

Add workflow to build technical documentation using full website #27

name: Build technical documentation
on:
pull_request:
paths: ["docs/sources/**"]
workflow_dispatch:
jobs:
docs-target:
runs-on: ubuntu-latest
outputs:
target: ${{ steps.target.outputs.target }}
steps:
- 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 }}
generate-token:
runs-on: ubuntu-latest
outputs:
token: ${{ steps.generate-token.outputs.token }}
steps:
- 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 }}
build-technical-documentation:
runs-on: ubuntu-latest
container:
image: grafana/docs-base:latest
needs:
- docs-target
- generate-token
steps:
- name: Checkout repository
uses: actions/checkout@v3
- 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: ${{ needs.generate-token.outputs.token }}
- 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: ${{ needs.docs-target.outputs.target }}
doc-validator:
runs-on: ubuntu-latest
container:
image: grafana/doc-validator:v3.2.1
needs: docs-target
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: Run doc-validator tool
# Only run doc-validator on specific directories.
run: >
doc-validator
"--include=^/hugo/content/docs/grafana/${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: ${{ needs.docs-target.outputs.target }}