diff --git a/README.md b/README.md index 1968b8e..73a97b2 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,11 @@ 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. | +| 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. | | 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 closing the repository. Should be of the form `"https://{GITHUB_ACTOR}:{TOKEN}@{GITHUB_HOST}/{GITHUB_REPOSITORY}.git`. When set, `token` will not be used. | + ## Usage diff --git a/action.yml b/action.yml index 7bd141f..65f7036 100644 --- a/action.yml +++ b/action.yml @@ -36,6 +36,8 @@ inputs: default: false tls_ca_cert: description: 'The CA certificate to use when connecting to BindPlane OP' + github_url: + description: 'The GitHub URL to use when connecting to GitHub' runs: using: 'docker' @@ -58,3 +60,4 @@ runs: - ${{ inputs.tls_ca_cert }} - ${{ inputs.source_path }} - ${{ inputs.processor_path }} + - ${{ inputs.github_url }} diff --git a/entrypoint.sh b/entrypoint.sh index 50e1ca9..6582d84 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -20,6 +20,7 @@ configuration_output_branch=${12} tls_ca_cert=${13} source_path=${14} processor_path=${15} +github_url=${16} # This branch name will be compared to target_branch to determine if the action # should apply or write back configurations. @@ -89,9 +90,12 @@ validate() { exit 1 fi + # A token or github_url are required when target_branch is set. if [ -z "$token" ]; then - echo "token is required when target_branch is set." - exit 1 + if [ -z "$github_url" ]; then + echo "token or github_url are required when target_branch is set." + exit 1 + fi fi # GITHUB_ACTOR and GITHUB_REPOSITORY are set by the github actions runtime @@ -127,12 +131,18 @@ write_back() { # write back branch will be the same as the target branch. write_back_branch=${configuration_output_branch:-$target_branch} + # if the github_url is set, use it, otherwise default to github.com + github_url=${github_url:-github.com} + if [ -z "$github_host" ]; then + github_url="https://${GITHUB_ACTOR}:${token}@github.com/${GITHUB_REPOSITORY}.git" + fi + # Clone the repo on the current branch # and use depth 1 to avoid cloning the entire history. git clone \ --depth 1 \ --branch "$write_back_branch" \ - "https://${GITHUB_ACTOR}:${token}@github.com/${GITHUB_REPOSITORY}.git" \ + "${github_url}" \ ../out_repo cd "../out_repo"