Skip to content

Commit a49ab19

Browse files
authored
[doc] fix workflow (RustPython#7021)
1 parent b993312 commit a49ab19

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

.github/workflows/update-doc-db.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Update doc DB
22

33
permissions:
44
contents: write
5+
pull-requests: write
56

67
on:
78
workflow_dispatch:
@@ -10,10 +11,10 @@ on:
1011
description: Target python version to generate doc db for
1112
type: string
1213
default: "3.14.3"
13-
ref:
14-
description: Branch to commit to (leave empty for current branch)
14+
base-ref:
15+
description: Base branch to create the update branch from
1516
type: string
16-
default: ""
17+
default: "main"
1718

1819
defaults:
1920
run:
@@ -56,9 +57,12 @@ jobs:
5657
steps:
5758
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v6.0.1
5859
with:
59-
ref: ${{ inputs.ref || github.ref }}
60+
ref: ${{ inputs.base-ref }}
6061
token: ${{ secrets.AUTO_COMMIT_PAT }}
6162

63+
- name: Create update branch
64+
run: git switch -c update-doc-${{ inputs.python-version }}
65+
6266
- name: Download generated doc DBs
6367
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
6468
with:
@@ -96,13 +100,18 @@ jobs:
96100
retention-days: 7
97101
overwrite: true
98102

99-
- name: Commit and push (non-main branches only)
100-
if: github.ref != 'refs/heads/main' && inputs.ref != 'main'
103+
- name: Commit, push and create PR
104+
env:
105+
GH_TOKEN: ${{ secrets.AUTO_COMMIT_PAT }}
101106
run: |
102107
git config user.name "github-actions[bot]"
103108
git config user.email "github-actions[bot]@users.noreply.github.com"
104109
if [ -n "$(git status --porcelain)" ]; then
105110
git add crates/doc/src/data.inc.rs
106111
git commit -m "Update doc DB for CPython ${{ inputs.python-version }}"
107-
git push
112+
git push -u origin HEAD
113+
gh pr create \
114+
--base ${{ inputs.base-ref }} \
115+
--title "Update doc DB for CPython ${{ inputs.python-version }}" \
116+
--body "Auto-generated by update-doc-db workflow."
108117
fi

0 commit comments

Comments
 (0)