-
Notifications
You must be signed in to change notification settings - Fork 3
101 lines (89 loc) · 3.16 KB
/
Copy pathgenerated-docs.yml
File metadata and controls
101 lines (89 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Generated Docs
on:
workflow_run:
workflows:
- CI
types:
- completed
workflow_dispatch:
permissions:
contents: read
jobs:
commit-generated-docs:
if: >-
github.event_name == 'workflow_dispatch' ||
(
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.head_branch == 'main'
)
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v7
with:
ref: main
fetch-depth: 0
persist-credentials: false
- name: Refresh branch
run: git pull --ff-only origin main
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Install pipx and Poetry
run: |
python -m pip install --upgrade pip pipx
python -m pipx ensurepath
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
pipx install poetry
- name: Install dependencies
run: poetry install --no-interaction --with dev
- name: Generate docs
run: |
poetry run sync-docs-readme
poetry run generate-cli-docs
poetry run generate-cli-man-docs
poetry run generate-ansible-docs
- name: Check docs
run: |
poetry run check-doc-links
poetry run check-doc-artifacts
- name: Commit generated docs
id: docs
run: |
echo "changed=false" >> "$GITHUB_OUTPUT"
if [ -z "$(git status --porcelain docs/cli docs/man docs/ansible)" ]; then
echo "Generated docs are up to date."
exit 0
fi
git config user.name "github-actions"
git config user.email "github-actions@users.noreply.cisco.com"
git add docs/cli docs/man docs/ansible
git commit -m "docs: update generated references"
echo "changed=true" >> "$GITHUB_OUTPUT"
- name: Push generated docs
if: steps.docs.outputs.changed == 'true'
env:
SCCFM_CI_DEPLOY_KEY: ${{ secrets.SCCFM_CI_DEPLOY_KEY }}
run: |
set -euo pipefail
SSH_ROOT="$(mktemp -d "${RUNNER_TEMP}/sccfm-docs-ssh.XXXXXX")"
cleanup_ssh() {
rm -rf "${SSH_ROOT}"
}
trap cleanup_ssh EXIT
umask 077
DEPLOY_KEY_PATH="${SSH_ROOT}/deploy-key"
KNOWN_HOSTS_PATH="${SSH_ROOT}/known-hosts"
test -n "${SCCFM_CI_DEPLOY_KEY}"
printf '%s\n' "${SCCFM_CI_DEPLOY_KEY}" > "${DEPLOY_KEY_PATH}"
chmod 600 "${DEPLOY_KEY_PATH}"
unset SCCFM_CI_DEPLOY_KEY
curl --fail --silent --show-error --location \
https://api.github.com/meta \
| jq -er '.ssh_keys[] | "github.com " + .' > "${KNOWN_HOSTS_PATH}"
test -s "${KNOWN_HOSTS_PATH}"
GIT_SSH_COMMAND="ssh -i ${DEPLOY_KEY_PATH} -o IdentitiesOnly=yes -o UserKnownHostsFile=${KNOWN_HOSTS_PATH} -o StrictHostKeyChecking=yes"
PUSH_REMOTE="git@github.com:${GITHUB_REPOSITORY}.git"
GIT_SSH_COMMAND="${GIT_SSH_COMMAND}" git push "${PUSH_REMOTE}" HEAD:main