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

fix: Skip commit message check if token not provided #51

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ BindPlane requires a license. You can request a free license [here](https://obse
| enable_otel_config_write_back | `false` | Whether or not the action should write the raw OpenTelemetry configurations back to the repository. |
| configuration_output_dir | | When write back is enabled, this is the path that will be written to. |
| configuration_output_branch | | The branch to write the OTEL configuration resources to. If unset, target_branch will be used. |
| token | | The Github token that will be used to write to the repo. Usually secrets.GITHUB_TOKEN is sufficient. Requires the `contents.write` permission. Alternatively, you can set `github_url`, which should contain your access token. |
| token | | The Github token that will be used to read and write to the repo. Usually secrets.GITHUB_TOKEN is sufficient. Requires the `contents.write` permission. Alternatively, you can set `github_url`, which should contain your access token. |
| enable_auto_rollout | `false` | When enabled, the action will trigger a rollout for any configuration that has been updated. |
| tls_ca_cert | | The contents of a TLS certificate authority, usually from a secret. See the [TLS](#tls) section. |
| github_url | | Optional URL to use when cloning the repository. Should be of the form `"https://{GITHUB_ACTOR}:{TOKEN}@{GITHUB_HOST}/{GITHUB_REPOSITORY}.git`. When set, `token` will not be used. |
Expand Down
30 changes: 17 additions & 13 deletions cmd/action/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,26 @@ func main() {
zap.Any("bindplane_version", version.Tag),
)

// Retrieve the commit message from the head commit on the branch
message, err := commitMessage(github_url, branch, token)
if err != nil {
logger.Error("error getting commit message", zap.Error(err))
os.Exit(exitClientError)
}

// If the commit message contains `progress rollout <name>`, progress the rollout
// for the configuration instead of running the full workflow.
if name, ok := extractConfigName(message); ok {
err := action.RunRollout(name)
if token != "" {
// Retrieve the commit message from the head commit on the branch
message, err := commitMessage(github_url, branch, token)
if err != nil {
logger.Error("error progressing rollout", zap.Error(err))
logger.Error("error getting commit message", zap.Error(err))
os.Exit(exitClientError)
}
return

// If the commit message contains `progress rollout <name>`, progress the rollout
// for the configuration instead of running the full workflow.
if name, ok := extractConfigName(message); ok {
err := action.RunRollout(name)
if err != nil {
logger.Error("error progressing rollout", zap.Error(err))
os.Exit(exitClientError)
}
return
}
} else {
logger.Info("Skipping commit message check, Github token not provided")
}

// Run the full workflow
Expand Down
Loading