Skip to content

Commit 1c70cb2

Browse files
authored
GitHub Action to generate and publish documentation (#78)
* GitHub Action to generate and publish documentation This generates a basic list of Steps that are made available by this library and publishes it to GitHub pages. Signed-off-by: Jonathan Dowland <jdowland@redhat.com> * gendocs.sh: generate links to source files on GitHub Signed-off-by: Jonathan Dowland <jdowland@redhat.com> --------- Signed-off-by: Jonathan Dowland <jdowland@redhat.com>
1 parent 2a5c755 commit 1c70cb2

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

.github/workflows/static.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Simple workflow for deploying static content to GitHub Pages
2+
name: Deploy static content to Pages
3+
4+
on:
5+
# Runs on pushes targeting the default branch
6+
push:
7+
branches:
8+
- "v1"
9+
- "gh-pages-doc-steps"
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
15+
permissions:
16+
contents: read
17+
pages: write
18+
id-token: write
19+
20+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
21+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
22+
concurrency:
23+
group: "pages"
24+
cancel-in-progress: false
25+
26+
jobs:
27+
# Single deploy job since we're just deploying
28+
deploy:
29+
environment:
30+
name: github-pages
31+
url: ${{ steps.deployment.outputs.page_url }}
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
- name: Setup Pages
37+
uses: actions/configure-pages@v5
38+
- name: Install Behave and related
39+
run: |
40+
pip3 install behave docker lxml markdown
41+
- name: Generate documentation
42+
run: |
43+
mkdir -p pages
44+
./tools/gendocs.sh > pages/index.html
45+
- name: Upload artifact
46+
uses: actions/upload-pages-artifact@v3
47+
with:
48+
path: 'pages'
49+
- name: Deploy to GitHub Pages
50+
id: deployment
51+
uses: actions/deploy-pages@v4

tools/gendocs.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# we expect to be run from the root of the behave-test-steps repository
5+
test -d steps
6+
7+
# necessary to stop behave quitting early
8+
mkdir -p features
9+
touch features/blank.feature
10+
11+
cat <<EOF
12+
<!doctype html>
13+
<html>
14+
<head>
15+
<meta charset="utf-8" />
16+
<title>behave-test-steps steps documentation</title>
17+
</head>
18+
<body>
19+
<header>
20+
<h1>behave-test-steps steps documentation</h1>
21+
</header>
22+
EOF
23+
24+
fork="cekit" # TODO: permit override from environment
25+
branch="v1"
26+
linkroot="https://github.com/${fork}/behave-test-steps/blob/${branch}/"
27+
28+
behave --dry-run --format=steps.catalog --no-summary |
29+
sed -E 's!^((Given|When|Then).*)$!## \1\n!' | # turn steps into Mdwn headers
30+
sed -E "s#Location: (.*):(.*)#[\1:\2](${linkroot}\1\#L\2)\n#" | # mdwn-link to the implementation
31+
sed -E 's#^ ##' | # stop preformatted descriptions # convert to HTML
32+
python3 -m markdown # convert to HTML
33+
34+
cat <<EOF
35+
36+
</body>
37+
</html>
38+
EOF

0 commit comments

Comments
 (0)