mirror of
https://github.com/apache/superset.git
synced 2026-05-28 19:25:20 +00:00
chore(ci): make country-map drift comment sticky
Every push to a country-map PR retriggers the regen workflow, which was stacking a fresh drift warning comment on every commit (15+ on this branch alone). Switch to the sticky-comment pattern: - Tag each drift comment with a hidden HTML marker - On drift: look up the existing tagged comment by ID and edit it in place, only posting a new one if none exists - On drift cleared: delete the existing tagged comment so the PR doesn't carry a stale warning Cleaned up the existing 15 stacked comments out of band. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
43
.github/workflows/country-map-build-regen.yml
vendored
43
.github/workflows/country-map-build-regen.yml
vendored
@@ -63,14 +63,51 @@ jobs:
|
||||
echo "Outputs match committed snapshot — nothing to do."
|
||||
fi
|
||||
|
||||
- name: Comment on PR if drift
|
||||
# Sticky comment: every push to a PR retriggers this workflow, so
|
||||
# we'd otherwise stack a fresh drift comment on every commit.
|
||||
# Look for an existing comment carrying our marker and edit it in
|
||||
# place; only post a new one the first time.
|
||||
- name: Comment on PR if drift (sticky)
|
||||
if: steps.drift.outputs.drift == 'true' && github.event_name == 'pull_request'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
REPO: ${{ github.repository }}
|
||||
COMMIT: ${{ github.event.pull_request.head.sha }}
|
||||
run: |
|
||||
gh pr comment "$PR_NUMBER" --repo "${{ github.repository }}" --body \
|
||||
"⚠️ Country Map: drift detected between locally committed GeoJSON outputs and CI-regenerated outputs. Either the YAML configs were updated without re-running \`./scripts/build.sh\`, OR mapshaper output differs cross-platform (macOS dev vs Linux CI). Investigate before merge."
|
||||
MARKER="<!-- country-map-drift-bot -->"
|
||||
BODY="$MARKER
|
||||
⚠️ **Country Map**: drift detected between the locally committed GeoJSON outputs and what CI just regenerated for commit \`${COMMIT:0:7}\`. Either the YAML configs were updated without re-running \`./scripts/build.sh\`, OR mapshaper output differs cross-platform (macOS dev vs Linux CI). Investigate before merge.
|
||||
|
||||
_This comment is sticky and updated on every push; old drift comments are not stacked._"
|
||||
|
||||
# Find an existing sticky comment by marker
|
||||
EXISTING=$(gh api "repos/${REPO}/issues/${PR_NUMBER}/comments" \
|
||||
--paginate --jq ".[] | select(.body | contains(\"${MARKER}\")) | .id" \
|
||||
| head -n1)
|
||||
|
||||
if [ -n "$EXISTING" ]; then
|
||||
gh api -X PATCH "repos/${REPO}/issues/comments/${EXISTING}" -f body="$BODY"
|
||||
else
|
||||
gh pr comment "$PR_NUMBER" --repo "$REPO" --body "$BODY"
|
||||
fi
|
||||
|
||||
# If a previous push had drift but this one doesn't, remove the
|
||||
# sticky comment so the PR doesn't carry a stale warning.
|
||||
- name: Clear sticky comment if drift resolved
|
||||
if: steps.drift.outputs.drift == 'false' && github.event_name == 'pull_request'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
REPO: ${{ github.repository }}
|
||||
run: |
|
||||
MARKER="<!-- country-map-drift-bot -->"
|
||||
EXISTING=$(gh api "repos/${REPO}/issues/${PR_NUMBER}/comments" \
|
||||
--paginate --jq ".[] | select(.body | contains(\"${MARKER}\")) | .id" \
|
||||
| head -n1)
|
||||
if [ -n "$EXISTING" ]; then
|
||||
gh api -X DELETE "repos/${REPO}/issues/comments/${EXISTING}"
|
||||
fi
|
||||
|
||||
# Informational only: cross-platform mapshaper output reproducibility
|
||||
# is still being worked through. Don't block PRs on drift; surface
|
||||
|
||||
Reference in New Issue
Block a user