@@ -40,11 +40,13 @@ jobs:
4040 - name : Close Existing PR and Branch
4141 env :
4242 GH_TOKEN : ${{ secrets.CLOUD_JAVA_BOT_GITHUB_TOKEN }}
43+ EVENT_NAME : ${{ github.event_name }}
44+ REPOSITORY : ${{ github.repository }}
4345 run : |
4446 set -x
4547 current_branch="update-librarian-googleapis-main"
4648
47- if [ "${{ github.event_name } }" = "pull_request" ]; then
49+ if [ "${EVENT_NAME }" = "pull_request" ]; then
4850 echo "PR Test: Skipping cleanup."
4951 else
5052 # Try to find an open pull request associated with the branch
5759
5860 # Delete the remote branch if it still exists (e.g. if no PR was open)
5961 echo "Checking if remote branch ${current_branch} exists..."
60- if gh api "repos/${{ github.repository } }/git/refs/heads/${current_branch}" --silent 2>/dev/null; then
62+ if gh api "repos/${REPOSITORY }/git/refs/heads/${current_branch}" --silent 2>/dev/null; then
6163 echo "Deleting remote branch ${current_branch}..."
62- gh api -X DELETE "repos/${{ github.repository } }/git/refs/heads/${current_branch}" || {
64+ gh api -X DELETE "repos/${REPOSITORY }/git/refs/heads/${current_branch}" || {
6365 echo "Error: Failed to delete remote branch ${current_branch}."
6466 exit 1
6567 }
@@ -131,6 +133,8 @@ jobs:
131133 if : steps.detect_librarian.outputs.has_changes == 'true'
132134 env :
133135 GH_TOKEN : ${{ secrets.CLOUD_JAVA_BOT_GITHUB_TOKEN }}
136+ EVENT_NAME : ${{ github.event_name }}
137+ REPOSITORY : ${{ github.repository }}
134138 PR_TITLE : " chore: update googleapis commitish to ${{ steps.commit.outputs.short_commit }}"
135139 PR_BODY : |
136140 Updated googleapis commitish in librarian.yaml to https://github.com/googleapis/googleapis/commit/${{ steps.commit.outputs.new_commit }}
@@ -139,7 +143,7 @@ jobs:
139143 run : |
140144 set -x
141145
142- if [ "${{ github.event_name } }" = "pull_request" ]; then
146+ if [ "${EVENT_NAME }" = "pull_request" ]; then
143147 echo "=== PR Test: DRY RUN MODE ACTIVE ==="
144148 echo "Would have checked out branch: update-librarian-googleapis-main"
145149 echo "Would have committed configs with title: $PR_TITLE"
@@ -174,7 +178,7 @@ jobs:
174178 fi
175179
176180 # Push to remote (force push to overwrite any stale branch on remote)
177- git remote add remote_repo https://cloud-java-bot:"${GH_TOKEN}@github.com/${{ github.repository }} .git" || git remote set-url remote_repo https://cloud-java-bot:"${GH_TOKEN}@github.com/${{ github.repository } }.git"
181+ git remote add remote_repo https://cloud-java-bot:"${GH_TOKEN}@github.com/${REPOSITORY} .git" || git remote set-url remote_repo https://cloud-java-bot:"${GH_TOKEN}@github.com/${REPOSITORY }.git"
178182 git fetch -q remote_repo
179183 git push -f remote_repo "${current_branch}"
180184
0 commit comments