Skip to content

Commit

Permalink
untested, it will be easier to test when --create is released
Browse files Browse the repository at this point in the history
  • Loading branch information
oliversun9 committed May 17, 2023
1 parent 455042d commit 18c5712
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ inputs:
required: true
input:
description: The Input path.
default: '.'
default: "."
required: false
draft:
description: The identifier of pushing to the BSR as a draft commit, when set to 'true' the action will push the module as draft with the branch name as draft name.
required: false
create_visibility:
description: The visibility of the BSR repository to be created with, if one needs to be created.
required: false
runs:
using: composite
steps:
Expand All @@ -23,4 +26,5 @@ runs:
env:
BUF_TOKEN: ${{ inputs.buf_token }}
DRAFT: ${{ inputs.draft }}
CREATE_VISIBILITY: ${{ create_visibility }}
run: $GITHUB_ACTION_PATH/push.bash ${{ inputs.input }}
13 changes: 13 additions & 0 deletions push.bash
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,17 @@ if [ "${DRAFT}" == "true" ]; then
BUF_ARGS=("--draft" "${GITHUB_REF_NAME}")
fi

if [ -n "${CREATE_VISIBILITY}"]; then
set +e
BUF_HELP_OUTPUT="$("${BUF_COMMAND}" push example --create --help 2>&1)" # need to verify this
set -e
if [[ "${BUF_HELP_OUTPUT}" == *"unknown flag: --create"* ]]; then
fail "The installed version of buf does not support creating repositories. Please use buf v1.19.0 or newer." # TODO: check if it's in 1.19.0 when it's released
fi
if [[ "${CREATE_VISIBILITY}" != "public" && "${CREATE_VISIBILITY}" != "private" ]]; then
fail "Must specify --create-visibility as either 'public' or 'private'"
fi
BUF_ARGS+=("--create" "--create-visibility" "${CREATE_VISIBILITY}")
fi

BUF_TOKEN="${BUF_TOKEN}" "${BUF_COMMAND}" "push" "${BUF_INPUT}" "${BUF_ARGS[@]}"

0 comments on commit 18c5712

Please sign in to comment.