Browse Source
fix: enhance error handling and improve document generation in Nuget Packages Version Change Detector workflow
pull/24805/head
maliming
2 days ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
2 changed files with
26 additions and
4 deletions
-
.github/scripts/update_dependency_changes.py
-
.github/workflows/nuget-packages-version-change-detector.yml
|
|
|
@ -26,6 +26,10 @@ def get_diff(base_ref): |
|
|
|
capture_output=True, |
|
|
|
text=True, |
|
|
|
) |
|
|
|
if result.returncode != 0: |
|
|
|
raise RuntimeError( |
|
|
|
f"Failed to get diff for base ref 'origin/{base_ref}': {result.stderr}" |
|
|
|
) |
|
|
|
return result.stdout |
|
|
|
|
|
|
|
|
|
|
|
@ -292,7 +296,9 @@ def main(): |
|
|
|
sections.insert(0, (version, section_text)) |
|
|
|
|
|
|
|
# Write document |
|
|
|
os.makedirs(os.path.dirname(DOC_PATH), exist_ok=True) |
|
|
|
doc_dir = os.path.dirname(DOC_PATH) |
|
|
|
if doc_dir: |
|
|
|
os.makedirs(doc_dir, exist_ok=True) |
|
|
|
with open(DOC_PATH, "w") as f: |
|
|
|
f.write(HEADER + "\n") |
|
|
|
for _, text in sections: |
|
|
|
|
|
|
|
@ -13,9 +13,13 @@ on: |
|
|
|
permissions: |
|
|
|
contents: read |
|
|
|
|
|
|
|
concurrency: |
|
|
|
group: dependency-changes-${{ github.event.pull_request.number }} |
|
|
|
cancel-in-progress: false |
|
|
|
|
|
|
|
jobs: |
|
|
|
label: |
|
|
|
if: ${{ !github.event.pull_request.draft && !startsWith(github.head_ref, 'auto-merge/') }} |
|
|
|
if: ${{ !github.event.pull_request.draft && !startsWith(github.head_ref, 'auto-merge/') && github.event.pull_request.head.repo.full_name == github.repository && !contains(github.event.head_commit.message, '[skip ci]') }} |
|
|
|
permissions: |
|
|
|
contents: write |
|
|
|
pull-requests: write |
|
|
|
@ -34,6 +38,9 @@ jobs: |
|
|
|
ref: ${{ github.event.pull_request.head.ref }} |
|
|
|
fetch-depth: 0 |
|
|
|
|
|
|
|
- name: Fetch base branch |
|
|
|
run: git fetch origin ${{ github.event.pull_request.base.ref }}:refs/remotes/origin/${{ github.event.pull_request.base.ref }} --depth=1 |
|
|
|
|
|
|
|
- uses: actions/setup-python@v5 |
|
|
|
with: |
|
|
|
python-version: '3.x' |
|
|
|
@ -42,8 +49,17 @@ jobs: |
|
|
|
|
|
|
|
- name: Commit changes |
|
|
|
run: | |
|
|
|
set -e |
|
|
|
git config user.name "github-actions[bot]" |
|
|
|
git config user.email "github-actions[bot]@users.noreply.github.com" |
|
|
|
git add "$DOC_PATH" |
|
|
|
git diff --staged --quiet || git commit -m "docs: update package version changes" |
|
|
|
git push |
|
|
|
if git diff --staged --quiet; then |
|
|
|
echo "No changes to commit." |
|
|
|
else |
|
|
|
git commit -m "docs: update package version changes [skip ci]" |
|
|
|
if ! git push; then |
|
|
|
echo "Error: Failed to push changes. This may be due to conflicts or permission issues." |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
echo "Successfully committed and pushed documentation changes." |
|
|
|
fi |
|
|
|
|