update .github/workflows/update-community-prs.yaml

This commit is contained in:
ggman12
2026-02-13 12:00:10 -05:00
parent 17098ae39a
commit f5465f0552
+41 -17
View File
@@ -48,28 +48,52 @@ jobs:
git fetch origin "$branch_name" git fetch origin "$branch_name"
git checkout "$branch_name" git checkout "$branch_name"
# Merge main into PR branch
git config user.name "github-actions[bot]" git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com" git config user.email "github-actions[bot]@users.noreply.github.com"
if git merge origin/main -m "Merge main to update schema"; then # Get the community submission file(s) and schema from this branch
# Regenerate schema for this PR's submission (adds any new tags) community_files=$(git diff --name-only origin/main...HEAD -- 'community/' 'schemas/')
python -m src.contributions.regenerate_pr_schema || true
if [ -z "$community_files" ]; then
# If there are changes, commit and push echo " No community/schema files found in PR #$pr_number, skipping"
if [ -n "$(git status --porcelain schemas/)" ]; then git checkout main
git add schemas/ continue
git commit -m "Update schema with new tags" fi
git push origin "$branch_name"
echo " Updated PR #$pr_number with schema changes" echo " Files to preserve: $community_files"
else
git push origin "$branch_name" # Save the community files content
echo " Merged main into PR #$pr_number" mkdir -p /tmp/pr_files
for file in $community_files; do
if [ -f "$file" ]; then
mkdir -p "/tmp/pr_files/$(dirname "$file")"
cp "$file" "/tmp/pr_files/$file"
fi fi
done
# Reset branch to main (clean slate)
git reset --hard origin/main
# Restore the community files
for file in $community_files; do
if [ -f "/tmp/pr_files/$file" ]; then
mkdir -p "$(dirname "$file")"
cp "/tmp/pr_files/$file" "$file"
fi
done
rm -rf /tmp/pr_files
# Regenerate schema with current main + this submission's tags
python -m src.contributions.regenerate_pr_schema || true
# Stage and commit all changes
git add community/ schemas/
if ! git diff --cached --quiet; then
git commit -m "Community submission (rebased on main)"
git push --force origin "$branch_name"
echo " Rebased PR #$pr_number onto main"
else else
echo " Merge conflict in PR #$pr_number, adding comment" echo " No changes needed for PR #$pr_number"
gh pr comment "$pr_number" --body $'⚠️ **Merge Conflict**\n\nAnother community submission was merged and this PR has conflicts.\n\nA maintainer may need to:\n1. Close this PR\n2. Remove the `approved` label from the original issue\n3. Re-add the `approved` label to regenerate the PR'
git merge --abort
fi fi
git checkout main git checkout main