Skip to content

Commit 2ea2bfa

Browse files
committed
ci: skip buf breaking until main carries the proto module
buf breaking diffs against main#subdir=proto, but proto/ first lands in this PR — the check can only fail before merge ('Module had no .proto files'). Gate it on the base branch actually having protos, and disable the action's PR comment which the job token lacks permission to post.
1 parent 11125a9 commit 2ea2bfa

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ jobs:
3838
# buf breaking needs main's history to diff against.
3939
fetch-depth: 0
4040

41+
# buf breaking can only diff against main once main actually carries
42+
# the proto module; before this PR series merges, main has no proto/
43+
# and `buf breaking` fails with "had no .proto files".
44+
- name: Check base branch has protos
45+
id: base
46+
run: |
47+
if git ls-tree -d origin/main proto | grep -q proto; then
48+
echo "has_proto=true" >> "$GITHUB_OUTPUT"
49+
else
50+
echo "has_proto=false" >> "$GITHUB_OUTPUT"
51+
fi
52+
4153
- uses: bufbuild/buf-action@v1
4254
with:
4355
input: proto
@@ -46,6 +58,11 @@ jobs:
4658
# failing the job on any unformatted .proto. Catches drift before
4759
# generated code can diverge.
4860
format: true
49-
# Only run breaking on PRs (push to main has nothing to diff against).
50-
breaking: ${{ github.event_name == 'pull_request' }}
61+
# Only run breaking on PRs (push to main has nothing to diff
62+
# against) and only once main carries the proto module.
63+
breaking: ${{ github.event_name == 'pull_request' && steps.base.outputs.has_proto == 'true' }}
5164
breaking_against: 'https://github.com/${{ github.repository }}.git#branch=main,subdir=proto'
65+
# The action's PR comment needs permissions the default
66+
# GITHUB_TOKEN of this job lacks ("Resource not accessible by
67+
# integration"); skip it.
68+
pr_comment: false

0 commit comments

Comments
 (0)