Skip to content

Commit 457a733

Browse files
authored
Allow us to manage documentation redirects (#2372)
1 parent 2639169 commit 457a733

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

.github/workflows/redirects.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
# Sync RTD redirects
3+
name: redirects
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
paths:
10+
- docs/redirects.yml
11+
- .github/workflows/redirects.yml
12+
13+
# Manually triggered using GitHub's UI
14+
workflow_dispatch:
15+
16+
jobs:
17+
docs:
18+
environment: release
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v2
22+
- uses: actions/setup-python@v4
23+
24+
- name: Upgrade Python toolchain
25+
run: python3 -m pip install --upgrade pip setuptools wheel
26+
27+
- name: Install readthedocs-cli
28+
run: python3 -m pip install readthedocs-cli
29+
30+
- name: Sync redirects
31+
run: rtd projects ansible-lint redirects sync -f docs/redirects.yml --wet-run
32+
env:
33+
RTD_TOKEN: ${{ secrets.RTD_TOKEN }}

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@
178178
html_theme_options = {
179179
"collapse_navigation": False,
180180
"analytics_id": "UA-128382387-1",
181+
# cspell:disable-next-line
182+
"tag_manager_id": "GTM-5FGNF6S",
181183
"style_nav_header_background": "#5bbdbf",
182184
"style_external_links": True,
183185
# 'canonical_url': "https://docs.ansible.com/ansible/latest/",

docs/redirects.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Authoritative list of redirects we have configured in RTD,
2+
# https://pypi.org/project/readthedocs-cli/
3+
---
4+
- type: page
5+
from_url: /rules/git-latest/
6+
to_url: /rules/latest/
7+
- type: page
8+
from_url: /rules/hg-latest/
9+
to_url: /rules/latest/
10+
- type: page
11+
from_url: /default_rules/index/
12+
to_url: /rules/
13+
# Keep this last or it will match all the other rules
14+
- type: sphinx_htmldir
15+
from_url: ""
16+
to_url: ""

tox.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ passenv =
4444
PYTEST_* # allows developer to define their own preferences
4545
PYTEST_REQPASS # needed for CI
4646
PY_COLORS
47+
RTD_TOKEN
4748
REQUESTS_CA_BUNDLE # https proxies
4849
SSL_CERT_FILE # https proxies
4950
LANG
@@ -161,6 +162,14 @@ commands =
161162
'print("\n" + "=" * 120 + f"\n\nDocumentation available under `file://\{index_file\}`\n\nTo serve docs, use `python3 -m http.server --directory \{docs_dir\} 0`\n\n" + "=" * 120)'
162163
changedir = {toxinidir}/docs
163164

165+
[testenv:redirects]
166+
description = Update documentation redirections for readthedocs
167+
deps =
168+
readthedocs-cli
169+
commands =
170+
# This assumes you loaded RTD_TOKEN in your environment
171+
rtd projects ansible-lint redirects sync -f docs/redirects.yml --wet-run
172+
164173
[testenv:eco]
165174
description = Perform ecosystem impact (downstream testing) https://github.com/ansible-community/ansible-lint/discussions/1403
166175
skip_install = true

0 commit comments

Comments
 (0)