From 6eacf3a5b14d3e8424bd8d8453c1387639556735 Mon Sep 17 00:00:00 2001 From: farhan Date: Tue, 30 Apr 2024 15:53:40 +0500 Subject: [PATCH] chore: Address PR change requests --- .github/workflows/update-geolite-database.yml | 61 ++++++++----------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/.github/workflows/update-geolite-database.yml b/.github/workflows/update-geolite-database.yml index 92be3144246d..8b94adac2dfb 100644 --- a/.github/workflows/update-geolite-database.yml +++ b/.github/workflows/update-geolite-database.yml @@ -9,8 +9,8 @@ on: default: 'master' env: - MAXMIND_URL: 'https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=${{ env.MAXMIND_LICENSE_KEY }}&suffix=tar.gz' - MAXMIND_SHA256_URL: 'https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=${{ env.MAXMIND_LICENSE_KEY }}&suffix=tar.gz.sha256' + MAXMIND_URL: 'https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=${{ secrets.MAXMIND_LICENSE_KEY }}&suffix=tar.gz' + MAXMIND_SHA256_URL: 'https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=${{ secrets.MAXMIND_LICENSE_KEY }}&suffix=tar.gz.sha256' TAR_FILE_NAME: 'GeoLite2-Country.tar.gz' TAR_SHA256_FILE_NAME: 'GeoLite2-Country.tar.gz.sha256' TAR_UNZIPPED_ROOT_PATTERN: 'GeoLite2-Country_*' @@ -59,45 +59,36 @@ jobs: echo 'Updates/changes detected, going to create PR.' fi - - name: Make a PR - id: make-pr - uses: peter-evans/create-pull-request@v6 - with: - branch: '${{ github.actor }}/geoip2-bot-update-country-database' - branch-suffix: short-commit-hash - commit-message: | - chore: geoip2: update maxmind geolite country database - - Commit generated by workflow `${{ github.workflow }}` - title: 'Update GeoLite Database' - body: | - PR generated by workflow `${{ github.workflow }}` - on behalf of @${{ github.actor }}. - - It's updating the [maxmind geolite country database](https://github.com/openedx/edx-platform/blob/master/common/static/data/geoip/GeoLite2-Country.mmdb) - assignees: '${{ github.triggering_actor }}' - reviewers: '${{ github.triggering_actor }}' - - - name: Merge PR - if: steps.make-pr.outcome == 'success' + - name: Setup git run: | - PR_URL='${{ steps.make-pr.outputs.pull-request-url }}' - PR_NUMBER=$(basename $PR_URL) - curl -X PUT -H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' \ - -H 'Accept: application/vnd.github.v3+json' \ - https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER/merge + git config --global user.email '${{ github.actor }}@users.noreply.github.com' + git config --global user.name '${{ github.actor }}' - - name: Delete Branch - if: steps.make-pr.outcome == 'success' + - name: Create a branch, commit the code and make a PR + id: create-pr run: | - SHORT_SHA=$(echo '${{ github.sha }}' | cut -c 1-7) - BRANCH_NAME='${{ github.actor }}/geoip2-bot-update-country-database-'$SHORT_SHA - git push origin --delete $BRANCH_NAME - echo "Successfully deleted the branch $BRANCH_NAME" + BRANCH="${{ github.actor }}/geoip2-bot-update-country-database-$(echo "${{ github.sha }}" | cut -c 1-7)" + git checkout -b $BRANCH + git add . + git status + git commit -m "chore: geoip2: update maxmind geolite country database" + git push --set-upstream origin $BRANCH + PR_URL=$(gh pr create \ + --title "Update GeoLite Database" \ + --body "PR generated by workflow `${{ github.workflow }}` on behalf of @${{ github.actor }}." \ + --head $BRANCH \ + --base 'master' \ + --assignee 'arbi-bom' \ + --reviewer 'arbi-bom' \ + | grep -o 'https://github.com/.*/pull/[0-9]*') + echo "PR Created: ${PR_URL}" + echo "pull-request-url=$PR_URL" >> $GITHUB_OUTPUT + env: + GH_TOKEN: ${{ github.token }} - name: Job summary run: | - PR_URL='${{ steps.make-pr.outputs.pull-request-url }}' + PR_URL=${{ steps.create-pr.outputs.pull-request-url }} if [[ -z '$PR_URL' ]]; then echo 'Error: PR creation unsuccessful; refer to the log for further details.' | tee -a "${GITHUB_STEP_SUMMARY}" exit 1