Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ${GITHUB_SHA} instead of HEAD to avoid race conditions #139

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
# Run breaking change detection against the `main` branch
- uses: bufbuild/buf-breaking-action@v1
with:
against: 'https://github.com/acme/weather.git#branch=main'
against: 'https://github.com/${GITHUB_REPOSITORY}.git#branch=main'
```

With this configuration, the `buf` CLI detects breaking changes between the Protobuf sources in the
Expand Down Expand Up @@ -91,7 +91,7 @@ Detect breaking changes in a sub-directory | [`examples/detect-in-directory.yaml

A common Buf workflow in GitHub Actions is to push the Protobuf sources in the current branch to the
[Buf Schema Registry][bsr] if no breaking changes are detected against the previous commit (where
`ref` is `HEAD~1`).
`ref` is `${GITHUB_SHA}~1`).

```yaml
on: # Apply to all pushes to `main`
Expand All @@ -108,7 +108,7 @@ jobs:
# Run breaking change detection against the last commit
- uses: bufbuild/buf-breaking-action@v1
with:
against: 'https://github.com/acme/weather.git#branch=main,ref=HEAD~1'
against: 'https://github.com/${GITHUB_REPOSITORY}.git#branch=main,ref=${GITHUB_SHA}~1'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would fail for pull_request events as the GITHUB_SHA is the last puhsed to the current branch: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
Could you validate this change works for push and pull_request event types?

```

### Run against input in sub-directory
Expand Down Expand Up @@ -140,7 +140,7 @@ steps:
- uses: bufbuild/buf-breaking-action@v1
with:
input: 'proto'
against: 'https://github.com/acme/weather.git#branch=main,ref=HEAD~1,subdir=proto'
against: 'https://github.com/${GITHUB_REPOSITORY}.git#branch=main,ref=${GITHUB_SHA}~1,subdir=proto'
```

[actions]: https://docs.github.com/actions
Expand Down
Loading