diff --git a/.github/workflows/update-geolite-database.yml b/.github/workflows/update-geolite-database.yml index d9ad767ce57e..4e850649e9f1 100644 --- a/.github/workflows/update-geolite-database.yml +++ b/.github/workflows/update-geolite-database.yml @@ -66,6 +66,20 @@ jobs: git config --global user.email '${{ github.actor }}@users.noreply.github.com' git config --global user.name '${{ github.actor }}' + - name: Close obsolete GeoLite update PRs + run: | + set -euo pipefail + gh pr list \ + --state open \ + --base 'release-ulmo' \ + --limit 100 \ + --json number,title,headRefName \ + --jq '.[] | select(.title == "Update GeoLite Database" and (.headRefName | contains("/geoip2-bot-update-country-database-"))) | .number' | \ + xargs -r -I{} gh pr close {} \ + --comment 'Superseded by a newer automated GeoLite database update. Please review the latest PR.' + env: + GH_TOKEN: ${{ secrets.GH_PAT_WITH_ORG }} + - name: Create a branch, commit the code and make a PR id: create-pr run: | @@ -75,9 +89,20 @@ jobs: git status git commit -m "chore: geoip2: update maxmind geolite country database" git push --set-upstream origin $BRANCH + cat > /tmp/pr_body.md <<'EOF' + PR generated by workflow `${{ github.workflow }}` on behalf of @${{ github.actor }}. + + ## Runbook + See: https://2u-internal.atlassian.net/wiki/spaces/AT/pages/3420061706/Runbook+GeoLite2+Country+Database+Update + + ## Actions Required + - [ ] Verify that only `common/static/data/geoip/GeoLite2-Country.mmdb` changed + - [ ] Wait for CI to pass + - [ ] Merge this PR + EOF PR_URL=$(gh pr create \ --title "Update GeoLite Database" \ - --body "PR generated by workflow `${{ github.workflow }}` on behalf of @${{ github.actor }}." \ + --body-file /tmp/pr_body.md \ --head $BRANCH \ --base 'release-ulmo' \ --reviewer 'edx/orbi-bom' \