♻️ refactor(workflow): enhance version extraction and workflow reliability
- add type hints to functions for better code clarity - fix version extraction logic to correctly access version from dictionary - improve error handling in workflow with better debugging information - update workflow to use pull request head ref for accurate file detection - add fallback to 'latest' version when extraction fails - enhance logging with old and new version display - rename script reference from .sh to .py in workflow step - modify checkout action to use head ref instead of default
This commit is contained in:
17
.github/workflows/renovate-app-version.yml
vendored
17
.github/workflows/renovate-app-version.yml
vendored
@@ -46,6 +46,7 @@ jobs:
|
||||
uses: actions/checkout@v5.0.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.head_ref }}
|
||||
|
||||
- uses: actions/setup-python@main
|
||||
with:
|
||||
@@ -60,9 +61,21 @@ jobs:
|
||||
- name: Get list of updated files by the last commit in this branch separated by space
|
||||
id: updated-files
|
||||
run: |
|
||||
echo "files=$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | tr '\n' ' ')" >> $GITHUB_OUTPUT
|
||||
# 当触发工作流的事件为 pull_request 时,github.sha 值为 github.ref 分支上的最后一次合并提交
|
||||
files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.pull_request.head.sha }} | tr '\n' ' ')
|
||||
if [ -z "$files" ]; then
|
||||
echo "❌ 错误:没有检测到文件变更"
|
||||
echo "github.sha = ${{ github.sha }}"
|
||||
echo "github.event.pull_request.head.sha = ${{ github.event.pull_request.head.sha }}"
|
||||
echo "当前分支最新的提交SHA: $(git rev-parse HEAD)"
|
||||
echo "💡 最近三次提交:"
|
||||
echo " $(git log -3)"
|
||||
exit 1
|
||||
else
|
||||
echo "files=$files" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Run renovate-app-version.sh on updated files
|
||||
- name: Run renovate-app-version.py on updated files
|
||||
run: |
|
||||
IFS=' ' read -ra files <<< "${{ steps.updated-files.outputs.files }}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user