Skip to content

Commit a16c02c

Browse files
committed
Add possibility to apply a commit with patch to docs when publishing
You can specify commit hash to apply when you build documentation. This allows to regenerate past version of the documentation by checking out the exact version tag that was used back then and applying the commit hash with fixes. This might help in fixing issues like #53646
1 parent 82c2a0f commit a16c02c

File tree

7 files changed

+94
-24
lines changed

7 files changed

+94
-24
lines changed

.github/workflows/publish-docs-to-s3.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ on: # yamllint disable-line rule:truthy
6060
required: false
6161
description: "Override the Airflow Version to use for the docs build"
6262
type: string
63+
apply-commits:
64+
required: false
65+
description: "Optionally apply commit hashes before building - to patch the docs (coma separated)"
66+
type: string
6367
permissions:
6468
contents: read
6569
jobs:
@@ -162,6 +166,7 @@ jobs:
162166
INCLUDE_SUCCESS_OUTPUTS: false
163167
VERBOSE: "true"
164168
EXTRA_BUILD_OPTIONS: ${{ needs.build-info.outputs.extra-build-options }}
169+
APPLY_COMMITS: ${{ inputs.apply-commits || '' }}
165170
steps:
166171
- name: "Cleanup repo"
167172
shell: bash
@@ -184,6 +189,20 @@ jobs:
184189
ref: ${{ inputs.ref }}
185190
fetch-depth: 0
186191
fetch-tags: true
192+
- name: "Apply patch commits if provided"
193+
run: |
194+
if [[ "${APPLY_COMMITS}" != "" ]]; then
195+
echo "Applying commits ${APPLY_COMMIT} to the docs"
196+
# Split APPLY_COMMITS by comma and apply each commit
197+
IFS=',' read -ra COMMIT_ARRAY <<< "${APPLY_COMMITS}"
198+
for APPLY_COMMIT in "${COMMIT_ARRAY[@]}"; do
199+
echo "Applying commit ${APPLY_COMMIT}"
200+
git fetch origin "${APPLY_COMMIT}"
201+
git cherry-pick "${APPLY_COMMIT}"
202+
done
203+
else
204+
echo "No commits provided to apply, skipping."
205+
fi
187206
- name: "Install Breeze from the ${{ inputs.ref }} reference"
188207
uses: ./.github/actions/breeze
189208
with:

dev/README_RELEASE_AIRFLOW.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,23 @@ Other available parameters can be found with:
411411
breeze workflow-run publish-docs --help
412412
```
413413
414+
In case you publish the documentation from branch, you can specify `--airflow-version` and `--airflow-base-version`
415+
parameters to specify which version of airflow you want to build the documentation for - as it cannot
416+
be automatically derived from tag name. Normally both are automatically derived from the tag name.
417+
418+
One of the interesting features of publishing this way is that you can also rebuild historical version of
419+
the documentation with patches applied to the documentation (if they can be applied cleanly).
420+
421+
Yoy should specify the `--apply-commits` parameter with the list of commits you want to apply
422+
separated by commas and the workflow will apply those commits to the documentation before
423+
building it. Example:
424+
425+
```shell script
426+
breeze workflow-run publish-docs --ref 3.0.3 --site-env staging \
427+
--apply-commits 4ae273cbedec66c87dc40218c7a94863390a380d,e61e9618bdd6be8213d277b1427f67079fcb1d9b \
428+
apache-airflow docker-stack task-sdk
429+
```
430+
414431
### Manually using GitHub Actions
415432
416433
There are two steps to publish the documentation:

dev/README_RELEASE_PROVIDERS.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,18 @@ The `--ref` parameter should be the tag of the release candidate you are publish
522522
The `--site-env` parameter should be set to `staging` for pre-release versions or `live` for final releases. the default option is `auto`
523523
if the tag is rc it publishes to `staging` bucket, otherwise it publishes to `live` bucket.
524524

525+
One of the interesting features of publishing this way is that you can also rebuild historical version of
526+
the documentation with patches applied to the documentation (if they can be applied cleanly).
527+
528+
Yoy should specify the `--apply-commits` parameter with the list of commits you want to apply
529+
separated by commas and the workflow will apply those commits to the documentation before
530+
building it. Example:
531+
532+
```shell script
533+
breeze workflow-run publish-docs --ref providers-apache-hive/9.0.0 --site-env live \
534+
--apply-commits 4ae273cbedec66c87dc40218c7a94863390a380d hive
535+
```
536+
525537
Other available parameters can be found with:
526538

527539
```shell

dev/breeze/doc/images/output_workflow-run_publish-docs.svg

Lines changed: 35 additions & 23 deletions
Loading
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9d78a242ea07f4467d68d6eb769c6e57
1+
d0677b79afb4dba327d26a35c97455b3

dev/breeze/src/airflow_breeze/commands/workflow_commands.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ def workflow_run():
8989
default=None,
9090
type=str,
9191
)
92+
@click.option(
93+
"--apply-commits",
94+
help="Apply commits before building the docs - for example to patch fixes "
95+
"to the docs (comma separated list of commits). ",
96+
default=None,
97+
type=str,
98+
)
9299
@argument_doc_packages
93100
def workflow_run_publish(
94101
ref: str,
@@ -99,6 +106,7 @@ def workflow_run_publish(
99106
skip_write_to_stable_folder: bool = False,
100107
airflow_version: str | None = None,
101108
airflow_base_version: str | None = None,
109+
apply_commits: str | None = None,
102110
):
103111
if os.environ.get("GITHUB_TOKEN", ""):
104112
get_console().print("\n[warning]Your authentication will use GITHUB_TOKEN environment variable.")
@@ -165,6 +173,7 @@ def workflow_run_publish(
165173
"exclude-docs": exclude_docs,
166174
"skip-write-to-stable-folder": skip_write_to_stable_folder,
167175
"build-sboms": "true" if "apache-airflow" in doc_packages else "false",
176+
"apply-commits": apply_commits if apply_commits else "",
168177
}
169178

170179
if airflow_version:

dev/breeze/src/airflow_breeze/commands/workflow_commands_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"options": [
2929
"--ref",
3030
"--skip-tag-validation",
31+
"--apply-commits",
3132
],
3233
},
3334
{

0 commit comments

Comments
 (0)