From 3f1ce9907dc7c16b89b634c62a1db6239437ad8a Mon Sep 17 00:00:00 2001 From: sriram veeraghanta Date: Wed, 6 Mar 2024 20:18:47 +0530 Subject: [PATCH] fix: auto merge fixes --- .github/workflows/auto-merge.yml | 37 +++++++++++--------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml index 60ebe5834..ed3814532 100644 --- a/.github/workflows/auto-merge.yml +++ b/.github/workflows/auto-merge.yml @@ -8,13 +8,13 @@ on: env: CURRENT_BRANCH: ${{ github.ref_name }} - SOURCE_BRANCH: ${{ secrets.SYNC_TARGET_BRANCH_NAME }} # The sync branch such as "sync/ce" - TARGET_BRANCH: ${{ secrets.TARGET_BRANCH }} # The target branch that you would like to merge changes like develop + SOURCE_BRANCH: ${{ secrets.SYNC_SOURCE_BRANCH_NAME }} # The sync branch such as "sync/ce" + TARGET_BRANCH: ${{ secrets.SYNC_TARGET_BRANCH_NAME }} # The target branch that you would like to merge changes like develop GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} # Personal access token required to modify contents and workflows - REVIEWER: ${{ secrets.REVIEWER }} + REVIEWER: ${{ secrets.SYNC_PR_REVIEWER }} jobs: - Check_Branch: + Check_Branch: runs-on: ubuntu-latest outputs: BRANCH_MATCH: ${{ steps.check-branch.outputs.MATCH }} @@ -27,7 +27,7 @@ jobs: else echo "MATCH=false" >> $GITHUB_OUTPUT fi - + Auto_Merge: if: ${{ needs.Check_Branch.outputs.BRANCH_MATCH == 'true' }} needs: [Check_Branch] @@ -41,6 +41,11 @@ jobs: with: fetch-depth: 0 # Fetch all history for all branches and tags + - name: Setup Git + run: | + git config user.name "GitHub Actions" + git config user.email "actions@github.com" + - name: Setup GH CLI and Git Config run: | type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y) @@ -50,20 +55,6 @@ jobs: sudo apt update sudo apt install gh -y - - id: git-author - name: Setup Git CLI from Github Token - run: | - VIEWER_JSON=$(gh api graphql -f query='query { viewer { name login databaseId }}' --jq '.data.viewer') - VIEWER_NAME=$(jq --raw-output '.name | values' <<< "${VIEWER_JSON}") - VIEWER_LOGIN=$(jq --raw-output '.login' <<< "${VIEWER_JSON}") - VIEWER_DATABASE_ID=$(jq --raw-output '.databaseId' <<< "${VIEWER_JSON}") - - USER_NAME="${VIEWER_NAME:-${VIEWER_LOGIN}}" - USER_EMAIL="${VIEWER_DATABASE_ID}+${VIEWER_LOGIN}@users.noreply.github.com" - - git config --global user.name ${USER_NAME} - git config --global user.email ${USER_EMAIL} - - name: Check for merge conflicts id: conflicts run: | @@ -88,10 +79,6 @@ jobs: - name: Create PR to Target Branch if: env.HAS_CONFLICTS == 'true' run: | - # Use GitHub CLI to create PR and specify author and committer - PR_URL=$(gh pr create --base $TARGET_BRANCH --head $SOURCE_BRANCH \ - --title "sync: merge conflicts need to be resolved" \ - --body "" \ - --reviewer $REVIEWER ) + # Replace 'username' with the actual GitHub username of the reviewer. + PR_URL=$(gh pr create --base $TARGET_BRANCH --head $SOURCE_BRANCH --title "sync: merge conflicts need to be resolved" --body "" --reviewer $REVIEWER) echo "Pull Request created: $PR_URL" -