2022-03-01 09:22:12 +00:00
|
|
|
---
|
|
|
|
name: Documentation
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
tags:
|
2022-03-01 18:05:28 +00:00
|
|
|
- "[0-9]+.[0-9]+.[0-9]+"
|
2022-03-01 09:22:12 +00:00
|
|
|
|
|
|
|
env:
|
|
|
|
COLORTERM: 'yes'
|
|
|
|
TERM: 'xterm-256color'
|
|
|
|
PYTEST_ADDOPTS: '--color=yes'
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
docs:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
if: github.repository == 'ansible-middleware/keycloak'
|
|
|
|
permissions:
|
|
|
|
actions: write
|
|
|
|
checks: write
|
|
|
|
contents: write
|
|
|
|
deployments: write
|
|
|
|
packages: write
|
|
|
|
pages: write
|
|
|
|
steps:
|
|
|
|
- name: Check out code
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
path: ansible_collections/middleware_automation/keycloak
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v2
|
|
|
|
with:
|
|
|
|
python-version: 3.9
|
|
|
|
|
|
|
|
- name: Install doc dependencies
|
|
|
|
run: |
|
|
|
|
python -m pip install --upgrade pip
|
|
|
|
pip install -r ansible_collections/middleware_automation/keycloak/docs/requirements.txt
|
|
|
|
pip install -r ansible_collections/middleware_automation/keycloak/requirements.txt
|
2022-03-30 15:31:15 +00:00
|
|
|
sudo apt install -y sed hub
|
2022-03-01 09:22:12 +00:00
|
|
|
|
|
|
|
- name: Create default collection path
|
|
|
|
run: |
|
|
|
|
mkdir -p /home/runner/.ansible/collections/ansible_collections
|
|
|
|
|
|
|
|
- name: Create doc directories and resources
|
|
|
|
run: |
|
|
|
|
mkdir -p ./docs/plugins ./docs/roles
|
|
|
|
cat ./docs/roles.rst.template > ./docs/roles/index.rst
|
|
|
|
antsibull-docs collection --use-current --squash-hierarchy --dest-dir docs/plugins middleware_automation.keycloak
|
|
|
|
for role_readme in roles/*/README.md; do ln -f -s ../../$role_readme ./docs/roles/$(basename $(dirname $role_readme)).md; echo " * :doc:\`$(basename $(dirname $role_readme))\`" >> ./docs/roles/index.rst; done
|
|
|
|
working-directory: ansible_collections/middleware_automation/keycloak
|
|
|
|
|
2022-03-30 15:31:15 +00:00
|
|
|
- name: Scan PR merges from latest tag
|
|
|
|
run: |
|
|
|
|
TYPES=("minor_changes" "major_changes" "bugfixes" "deprecated_features" "removed_features")
|
|
|
|
TAG=$(git describe --abbrev=0 --tags)
|
|
|
|
PRS=($(comm -12 <(git log --oneline ${TAG}.. --format="tformat:%H" | sort ) <(hub pr list -s all -f '%sm%n' --color=never | sort )))
|
|
|
|
IFS=$'\n' FRAGMENTS=($(hub pr list -s all -f '%sm~%I~%L~%t~%n' --color=never| grep -P "$(echo "^(${PRS[@]})" | tr ' ' '|')"))
|
|
|
|
for frag in "${FRAGMENTS[@]}"; do
|
|
|
|
PR=$(echo $frag|cut -d~ -f2)
|
|
|
|
type="$(echo $frag|cut -d~ -f3)"
|
|
|
|
msg="$(echo $frag|cut -d~ -f4|sed 's/`/``/g')"
|
|
|
|
if [[ "${TYPES[*]}" =~ "${type}" ]]; then
|
|
|
|
echo -e "$type:\n - >\n $msg \`#${PR}<https://github.com/ansible-middleware/keycloak/pull/${PR}>\`" \
|
|
|
|
> changelogs/fragments/${PR}.yaml
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
antsibull-changelog lint -vvv
|
2022-03-31 12:56:41 +00:00
|
|
|
if [[ "${{github.ref}}" == "refs/heads/main" ]]; then
|
2022-03-31 13:04:55 +00:00
|
|
|
antsibull-changelog release --version "$(grep version galaxy.yml | awk -F'"' '{ print $2 }')-devel" -v
|
2022-03-31 12:56:41 +00:00
|
|
|
fi
|
2022-03-30 15:31:15 +00:00
|
|
|
working-directory: ansible_collections/middleware_automation/keycloak
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
2022-03-01 09:22:12 +00:00
|
|
|
- name: Run sphinx
|
|
|
|
run: |
|
|
|
|
sphinx-build -M html . _build -v
|
|
|
|
working-directory: ansible_collections/middleware_automation/keycloak/docs/
|
|
|
|
|
|
|
|
- name: Commit docs
|
|
|
|
run: |
|
|
|
|
git config user.name github-actions
|
|
|
|
git config user.email github-actions@github.com
|
2022-03-31 13:13:30 +00:00
|
|
|
git stash
|
2022-03-01 09:22:12 +00:00
|
|
|
git checkout gh-pages
|
|
|
|
rm -rf $(basename ${GITHUB_REF})
|
|
|
|
mv docs/_build/html $(basename ${GITHUB_REF})
|
|
|
|
ln --force --no-dereference --symbolic main latest
|
|
|
|
git show origin/main:docs/_gh_include/header.inc > index.html
|
|
|
|
(echo main; echo latest; dirname *.*.*/index.html | sort --version-sort --reverse) | xargs -I@@ -n1 echo '<li class="toctree-l1"><a class="reference internal" href="@@/">@@</a></li>' >> index.html
|
|
|
|
git show origin/main:docs/_gh_include/footer.inc >> index.html
|
|
|
|
git add $(basename ${GITHUB_REF}) latest index.html
|
|
|
|
git commit -m "Update docs for $(basename ${GITHUB_REF})" || true
|
|
|
|
git push origin gh-pages
|
|
|
|
working-directory: ansible_collections/middleware_automation/keycloak/
|