Skip to content

Commit 91b057d

Browse files
iscai-msftCopilot
andcommitted
fix: improve typespec-python regeneration workflow
- Fix README template step to create README.md in all package dirs, not just replace existing ones. This ensures newly generated packages (e.g. typeddict variants) always get a README. - Add target_branch input to workflow_dispatch so manual runs can push to a separate branch without affecting the main baseline. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 76955c3 commit 91b057d

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

.github/workflows/typespec-python-regenerate.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ on:
1616
description: "Either 'main' (microsoft/typespec@main) or a microsoft/typespec pull request URL (e.g. https://github.com/microsoft/typespec/pull/1234). The PR's head repo + SHA will be checked out."
1717
required: false
1818
default: "main"
19+
target_branch:
20+
description: "Branch to push regenerated tests to. Defaults to 'typespec-python-generated-tests'."
21+
required: false
22+
default: "typespec-python-generated-tests"
1923

2024
permissions:
2125
contents: write
@@ -148,19 +152,23 @@ jobs:
148152
echo "::error::Template README not found at $TEMPLATE"
149153
exit 1
150154
fi
151-
# Replace every README.md under generated/ with the template, except:
152-
# - the top-level generated/README.md
153-
# - anything under generated/template/ (the template itself and any
154-
# future siblings)
155-
find "$TARGET" -type f -name README.md \
156-
! -path "$TARGET/README.md" \
157-
! -path "$TARGET/template/*" \
158-
-print -exec cp -f "$TEMPLATE" {} \;
155+
# Place a README.md in every package directory under azure/ and
156+
# unbranded/ (top-level subdirectories only). This ensures newly
157+
# generated packages get a README, not just pre-existing ones.
158+
for flavor in azure unbranded; do
159+
flavor_dir="$TARGET/$flavor"
160+
[ -d "$flavor_dir" ] || continue
161+
for pkg_dir in "$flavor_dir"/*/; do
162+
[ -d "$pkg_dir" ] || continue
163+
cp -f "$TEMPLATE" "$pkg_dir/README.md"
164+
echo " $pkg_dir/README.md"
165+
done
166+
done
159167
160168
- name: Commit and push to dedicated branch
161169
run: |
162170
set -euo pipefail
163-
BRANCH="typespec-python-generated-tests"
171+
BRANCH="${{ github.event.inputs.target_branch || 'typespec-python-generated-tests' }}"
164172
git config user.name "github-actions[bot]"
165173
git config user.email "github-actions[bot]@users.noreply.github.com"
166174

0 commit comments

Comments
 (0)