From ba4367d0ef48d4a324b2a299e807f21d6854f4ce Mon Sep 17 00:00:00 2001 From: Superset Dev Date: Thu, 14 May 2026 16:43:29 -0700 Subject: [PATCH] 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 --- .github/workflows/country-map-build-regen.yml | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/.github/workflows/country-map-build-regen.yml b/.github/workflows/country-map-build-regen.yml index 2732149edd8..6c6fe617f35 100644 --- a/.github/workflows/country-map-build-regen.yml +++ b/.github/workflows/country-map-build-regen.yml @@ -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="" + 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="" + 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