Skip to content

Commit ba6f376

Browse files
committed
add test mode
1 parent 879071d commit ba6f376

1 file changed

Lines changed: 23 additions & 7 deletions

File tree

.github/workflows/update_librarian_googleapis.yaml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ on:
1717
schedule:
1818
- cron: '0 3 * * *' # Run once a day at 3:00 AM UTC
1919
workflow_dispatch: # Allow manual trigger
20+
pull_request: # Run in dry-run mode to test changes to this workflow itself
21+
paths:
22+
- '.github/workflows/update_librarian_googleapis.yaml'
2023
jobs:
2124
update-librarian-googleapis:
2225
runs-on: ubuntu-24.04
@@ -37,13 +40,17 @@ jobs:
3740
set -x
3841
current_branch="update-librarian-googleapis-main"
3942
40-
# Try to find an open pull request associated with the branch
41-
pr_num=$(gh pr list -s open -H "${current_branch}" -q . --json number | jq ".[] | .number")
42-
43-
if [ -n "${pr_num}" ]; then
44-
echo "Error: An open Pull Request already exists for this update: PR #${pr_num}."
45-
echo "Please merge or close the existing PR before running this workflow again."
46-
exit 1 # Fails this step and the workflow
43+
if [ "${{ github.event_name }}" = "pull_request" ]; then
44+
echo "PR Test: Skipping open PR check."
45+
else
46+
# Try to find an open pull request associated with the branch
47+
pr_num=$(gh pr list -s open -H "${current_branch}" -q . --json number | jq ".[] | .number")
48+
49+
if [ -n "${pr_num}" ]; then
50+
echo "Error: An open Pull Request already exists for this update: PR #${pr_num}."
51+
echo "Please merge or close the existing PR before running this workflow again."
52+
exit 1 # Fails this step and the workflow
53+
fi
4754
fi
4855
- name: Set up Go
4956
uses: actions/setup-go@v5
@@ -84,6 +91,15 @@ jobs:
8491
PR_BODY: ${{ steps.detect.outputs.body }}
8592
run: |
8693
set -x
94+
95+
if [ "${{ github.event_name }}" = "pull_request" ]; then
96+
echo "=== PR Test: DRY RUN MODE ACTIVE ==="
97+
echo "Would have checked out branch: update-librarian-googleapis-main"
98+
echo "Would have committed with title: $PR_TITLE"
99+
echo "Would have pushed branch and created PR."
100+
exit 0
101+
fi
102+
87103
[ -z "$(git config user.email)" ] && git config --global user.email "cloud-java-bot@google.com"
88104
[ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot"
89105

0 commit comments

Comments
 (0)