Skip to content

Commit 6e3bf40

Browse files
committed
👷 API docs now pulls branch and commits on top of it
This way PRs stack with updated commits
1 parent 7d83e4a commit 6e3bf40

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

.github/scripts/api_deploy.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,13 @@ def create_pr_or_update_branch_on_api_repo(
212212
print(f"Switching to branch: {branch_name}")
213213
api_repo.git.checkout('-B', branch_name)
214214

215+
# Pull remote branch contents if it exists so we commit on top
216+
try:
217+
api_repo.git.pull('origin', branch_name)
218+
print(f"Pulled latest from origin/{branch_name}")
219+
except GitCommandError:
220+
print(f"No existing remote branch '{branch_name}' to pull.")
221+
215222
# Create repo directory if it doesn't exist
216223
repo_dir = os.path.join(temp_dir, repo_name)
217224
os.makedirs(repo_dir, exist_ok=True)
@@ -250,11 +257,8 @@ def create_pr_or_update_branch_on_api_repo(
250257
print("Adding remote 'origin' with access token")
251258
origin = api_repo.create_remote("origin", auth_url)
252259

253-
# Force Push because we allow APIs for a specific version to
254-
# reflect the latest representation of the version/ref.
255260
print(f"Pushing branch to remote...")
256-
api_repo.git.push('--force', '--set-upstream',
257-
'origin', branch_name)
261+
api_repo.git.push('--set-upstream', 'origin', branch_name)
258262

259263
# Check if PR already exists
260264
existing_pr = check_existing_pr(

.github/workflows/api_docs_gen.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ on:
3232
dry_run:
3333
type: boolean
3434
default: false
35+
api_deploy_version:
36+
type: string
37+
default: 5.x.y
3538

3639
jobs:
3740
generate_api_docs:
@@ -51,7 +54,7 @@ jobs:
5154
- run: pip install -r ${{ inputs.dir }}/docs/requirements.txt gitpython requests
5255
- run: conan config install https://github.com/libhal/conan-config2.git
5356
- run: conan hal docs --doc_version ${{ inputs.version }} ${{ inputs.dir }}/docs
54-
- run: wget https://raw.githubusercontent.com/libhal/ci/5.x.y/.github/scripts/api_deploy.py
57+
- run: wget https://raw.githubusercontent.com/libhal/ci/${{ inputs.api_deploy_version }}/.github/scripts/api_deploy.py
5558
- name: Deploy to API repo
5659
if: ${{ inputs.dry_run == false }}
5760
run: python api_deploy.py deploy --version ${{ inputs.version }} --repo-name ${{ inputs.repo_name }} --docs-dir ${{ inputs.dir }}/docs/build/

.github/workflows/self_check.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
filters: |
4747
api_docs:
4848
- '.github/workflows/api_docs_gen.yml'
49+
- '.github/scripts/api_deploy.yml'
4950
library_check:
5051
- '.github/workflows/library_check.yml'
5152
tests:
@@ -70,6 +71,7 @@ jobs:
7071
dir: .
7172
dry_run: true
7273
version: main
74+
api_deploy_version: ${{ github.ref }}
7375
secrets: inherit
7476

7577
api_libhal_v4:
@@ -82,6 +84,7 @@ jobs:
8284
dir: v4
8385
dry_run: true
8486
version: main
87+
api_deploy_version: ${{ github.ref_name }}
8588
secrets: inherit
8689

8790
library_check_libhal_v4:

0 commit comments

Comments
 (0)