Skip to content

Commit 20a9cfa

Browse files
authored
fix: use the documentation site path in workflow (#1866)
1 parent f9e153e commit 20a9cfa

File tree

9 files changed

+78
-16
lines changed

9 files changed

+78
-16
lines changed

.github/workflows/documentation.yaml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ on: # yamllint disable-line rule:truthy
55
push:
66
paths:
77
- ".github/workflows/documentation.yaml"
8-
- "docs-src/**"
8+
- "websites-src/home-lab-docs/**"
99
- "config/mkdocs/home-lab-docs/**"
1010
- scripts/run-mkdocs.sh
1111
pull_request:
1212
paths:
1313
- ".github/workflows/documentation.yaml"
14-
- "docs-src/**"
14+
- "websites-src/home-lab-docs/**"
1515
- "config/mkdocs/home-lab-docs/**"
1616
- scripts/run-mkdocs.sh
1717
workflow_call: null
@@ -25,7 +25,7 @@ jobs:
2525
# Ref: https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
2626
# github.head_ref: head_ref or source branch of the pull request
2727
# github.ref: ref of the branch that triggered the workflow
28-
group: ${{ github.workflow }}-build-documentation-sites-${{ github.head_ref || github.ref }}-${{ github.event_name }}
28+
group: ${{ github.workflow }}-build-push-documentation-site-${{ github.head_ref || github.ref }}-${{ github.event_name }}
2929
cancel-in-progress: true
3030
permissions:
3131
# To commit the newly built documentation site
@@ -36,11 +36,24 @@ jobs:
3636
- name: Build the documentation site
3737
run: |
3838
scripts/run-mkdocs.sh "build" "home-lab-docs"
39+
# Check if changed files only include files that we can ignore, such as
40+
# when only updating the sitemap
41+
- name: Check documentation updates
42+
id: check_documentation_updates
43+
run: |
44+
. scripts/common.sh
45+
ONLY_CONTAINS_FILES_TO_IGNORE="false"
46+
if check_if_uncommitted_files_only_include_files_to_ignore; then
47+
echo "Documentation commit only contains files to ignore"
48+
ONLY_CONTAINS_FILES_TO_IGNORE="true"
49+
fi
50+
echo "ONLY_CONTAINS_FILES_TO_IGNORE=${ONLY_CONTAINS_FILES_TO_IGNORE}" >>"$GITHUB_OUTPUT"
3951
- name: Commit and push updates to the documentation site
4052
if: >
4153
github.event.pull_request.user.login != 'dependabot[bot]' &&
4254
github.event_name == 'pull_request' &&
43-
github.ref_name != github.event.repository.default_branch
55+
github.ref_name != github.event.repository.default_branch &&
56+
steps.check_documentation_updates.outputs.ONLY_CONTAINS_FILES_TO_IGNORE == 'false'
4457
uses: stefanzweifel/[email protected]
4558
with:
4659
branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }}

scripts/build-arduino-project.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#!/usr/bin/env sh
1+
#!/usr/bin/env bash
22

33
set -o errexit
44
set -o nounset
5+
set -o pipefail
56

67
SCRIPT_DIRECTORY_PATH="$(dirname "${0}")"
78

scripts/common.sh

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#!/usr/bin/env sh
1+
#!/usr/bin/env bash
22

33
set -o errexit
44
set -o nounset
5+
set -o pipefail
56

67
# shellcheck disable=SC2034
78
ERR_ARGUMENT_EVAL=2
@@ -18,6 +19,12 @@ GITHUB_TOKEN_PATH="$(pwd)/.github-personal-access-token"
1819
# shellcheck disable=SC2034
1920
HOME_LAB_DOCS_CONFIGURATION_FILE_PATH="config/mkdocs/home-lab-docs/mkdocs.yml"
2021

22+
# shellcheck disable=SC2034
23+
MKDOCS_IGNORE_IF_ONLY_CHANGED_FILES=(
24+
"docs/sitemap.xml"
25+
"docs/sitemap.xml.gz"
26+
)
27+
2128
_DOCKER_INTERACTIVE_TTY_OPTION=
2229
if [ -t 0 ]; then
2330
_DOCKER_INTERACTIVE_TTY_OPTION="-it"
@@ -40,7 +47,7 @@ is_container_runtime_available() {
4047
}
4148

4249
activate_python_virtual_environment() {
43-
VENV_PATH="${1}"
50+
local VENV_PATH="${1}"
4451

4552
if [ -z "${VIRTUAL_ENV-}" ]; then
4653
echo "Activating the virtual environment in ${VENV_PATH}"
@@ -54,7 +61,7 @@ activate_python_virtual_environment() {
5461
}
5562

5663
is_python_virtual_environment_up_to_date() {
57-
PYTHON_VIRTUAL_ENVIRONMENT_CHECK_RETURN_CODE=0
64+
local PYTHON_VIRTUAL_ENVIRONMENT_CHECK_RETURN_CODE=0
5865
if [ ! -e "${1}" ]; then
5966
# The virtual environment doesn't exist, so it can't be up to date by definition
6067
PYTHON_VIRTUAL_ENVIRONMENT_CHECK_RETURN_CODE=1
@@ -74,9 +81,9 @@ is_python_virtual_environment_up_to_date() {
7481
}
7582

7683
create_and_activate_python_virtual_environment() {
77-
PYTHON_VIRTUAL_ENVIRONMENT_PATH="${1}"
78-
PIP_REQUIREMENTS_PATH="${2:-""}"
79-
_FORCE_UPDATE_PYTHON_VIRTUAL_ENVIRONMENT="${3:-"false"}"
84+
local PYTHON_VIRTUAL_ENVIRONMENT_PATH="${1}"
85+
local PIP_REQUIREMENTS_PATH="${2:-""}"
86+
local _FORCE_UPDATE_PYTHON_VIRTUAL_ENVIRONMENT="${3:-"false"}"
8087

8188
if [ -e "${PYTHON_VIRTUAL_ENVIRONMENT_PATH}" ] && ! is_python_virtual_environment_up_to_date "${PYTHON_VIRTUAL_ENVIRONMENT_PATH}" && [ "${_FORCE_UPDATE_PYTHON_VIRTUAL_ENVIRONMENT}" = "true" ]; then
8289
echo "The ${PYTHON_VIRTUAL_ENVIRONMENT_PATH} virtual environment already exists but it's not up to date. Deleting it..."
@@ -123,3 +130,34 @@ check_github_token_file() {
123130
exit "${ERR_MISSING_GITHUB_TOKEN_FILE}"
124131
fi
125132
}
133+
134+
check_if_uncommitted_files_only_include_files() {
135+
local -a FILES_TO_CHECK=("$@")
136+
local -a CHANGED_FILES
137+
138+
git status
139+
140+
readarray -d '' -t CHANGED_FILES < <(git diff-files -z --name-only)
141+
readarray -d '' -t SORTED_CHANGED_FILES < <(printf '%s\0' "${CHANGED_FILES[@]}" | sort -z)
142+
143+
echo "Changed files (${#SORTED_CHANGED_FILES[@]}) in working directory:"
144+
echo "${SORTED_CHANGED_FILES[*]}"
145+
146+
readarray -d '' -t SORTED_FILES_TO_CHECK < <(printf '%s\0' "${FILES_TO_CHECK[@]}" | sort -z)
147+
148+
if [[ "${SORTED_CHANGED_FILES[*]}" == "${SORTED_FILES_TO_CHECK[*]}" ]]; then
149+
echo "Working directory contains only the files to check"
150+
return 0
151+
else
152+
echo "Working directory doesn't contain only the files to check"
153+
return 1
154+
fi
155+
}
156+
157+
check_if_uncommitted_files_only_include_files_to_ignore() {
158+
if check_if_uncommitted_files_only_include_files "${MKDOCS_IGNORE_IF_ONLY_CHANGED_FILES[@]}"; then
159+
return 0
160+
else
161+
return 1
162+
fi
163+
}

scripts/copy-data.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
#!/usr/bin/env sh
1+
#!/usr/bin/env bash
22
# shellcheck disable=SC2029
33
# Disable SC2029 because intend to expand variables on the client
44
# that runs this script, not on the server
55

66
set -o errexit
77
set -o nounset
8+
set -o pipefail
89

910
_SOURCE_HOST="${1}"
1011
_SOURCE_DIRECTORY="${2}"

scripts/open-shell-ci-cd-tools-container.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#!/usr/bin/env sh
1+
#!/usr/bin/env bash
22

33
set -o errexit
44
set -o nounset
5+
set -o pipefail
56

67
# shellcheck disable=SC1091,SC1094
78
. ./scripts/common.sh

scripts/release-please-dry-run.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#!/usr/bin/env sh
1+
#!/usr/bin/env bash
22

33
set -o errexit
44
set -o nounset
5+
set -o pipefail
56

67
# shellcheck disable=SC1091,SC1094
78
. ./scripts/common.sh

scripts/run-ansible.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#!/usr/bin/env sh
1+
#!/usr/bin/env bash
22

33
set -o errexit
44
set -o nounset
5+
set -o pipefail
56

67
# Doesn't follow symlinks, but it's likely expected for most users
78
SCRIPT_BASENAME="$(basename "${0}")"

scripts/run-mkdocs.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/usr/bin/env bash
22

3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
6+
37
# shellcheck source=/dev/null
48
. "./scripts/common.sh"
59

@@ -54,6 +58,7 @@ if [[ "${SUBCOMMAND}" == "serve" ]]; then
5458
elif [[ "${SUBCOMMAND}" == "build" ]]; then
5559
RUN_CONTAINER_COMMAND+=(
5660
"build"
61+
"--strict"
5762
"${DEFAULT_MKDOCS_ARGS[@]}"
5863
)
5964
elif [[ "${SUBCOMMAND}" == "create" ]]; then

scripts/run-pre-commit.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#!/usr/bin/env sh
1+
#!/usr/bin/env bash
22

33
set -o errexit
44
set -o nounset
5+
set -o pipefail
56

67
# Doesn't follow symlinks, but it's likely expected for most users
78
SCRIPT_BASENAME="$(basename "${0}")"

0 commit comments

Comments
 (0)