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: support token with space like Bearer xxxxx #155

Merged
merged 7 commits into from
Sep 17, 2024
Merged
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
47 changes: 24 additions & 23 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,57 +67,58 @@ runs:
if [[ -n "${{ inputs.config }}" ]]
then
echo "using config from '${{ inputs.config }}'"
CONFIG_PATH="--config ${{ inputs.config }}"
# Use arrays so that inputs can contain spaces
CONFIG_PATH=("--config" "${{ inputs.config }}")
davidB marked this conversation as resolved.
Show resolved Hide resolved
else
CONFIG_PATH=""
CONFIG_PATH=()
fi

if [[ -n "${{ inputs.token }}" ]]
then
echo "using custom registry token'"
TOKEN="--token ${{ inputs.token }}"
TOKEN=("--token" "${{ inputs.token }}")
else
TOKEN=""
TOKEN=()
fi

if [[ -n "${{ inputs.backend }}" ]]
then
echo "using backend '${{ inputs.backend }}'"
BACKEND="--backend ${{ inputs.backend }}"
BACKEND=("--backend" "${{ inputs.backend }}")
else
BACKEND=""
BACKEND=()
fi

if [[ -n "${{ inputs.registry }}" ]]
then
echo "using registry '${{ inputs.registry }}'"
ALT_REGISTRY="--registry ${{ inputs.registry }}"
ALT_REGISTRY=("--registry" "${{ inputs.registry }}")
else
ALT_REGISTRY=""
ALT_REGISTRY=()
fi

if [[ -n "${{ inputs.manifest_path }}" ]]
then
echo "using manifest path '${{ inputs.manifest_path }}'"
MANIFEST_PATH="--manifest-path ${{ inputs.manifest_path }}"
MANIFEST_PATH=("--manifest-path" "${{ inputs.manifest_path }}")
elif [[ -n "${{ inputs.project_manifest }}" ]]
then
echo "using manifest path '${{ inputs.project_manifest }}'"
MANIFEST_PATH="--project-manifest ${{ inputs.project_manifest }}"
MANIFEST_PATH=("--project-manifest" "${{ inputs.project_manifest }}")
else
MANIFEST_PATH=""
MANIFEST_PATH=()
fi

if [[ -z "${{ inputs.command }}" || "${{ inputs.command }}" == "release-pr" ]]
then
echo "-- Running release-plz release-pr --"
release_pr_output=$(release-plz release-pr\
--git-token ${GITHUB_TOKEN}\
--repo-url https://github.com/${GITHUB_REPOSITORY}\
${CONFIG_PATH}\
${ALT_REGISTRY}\
${MANIFEST_PATH}\
${BACKEND}\
--git-token "${GITHUB_TOKEN}"\
--repo-url "https://github.com/${GITHUB_REPOSITORY}"\
"${CONFIG_PATH[@]}"\
"${ALT_REGISTRY[@]}"\
"${MANIFEST_PATH[@]}"\
"${BACKEND[@]}"\
Copy link
Member

Choose a reason for hiding this comment

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

is this trick used to work with whitespace? If yes, why are we using it also in the backend, which is one world only?
Same for ALT_REGISTRY probably

Choose a reason for hiding this comment

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

yes this trick is to keep the separation of argument clean as defined in the array. I also apply it BACKEND and ALT_REGISTRY for:

  • consistency (same pattern for every arguments fragment)
  • to guide if new argument should be added in the future (no question about which "form" to use)

-o json)
echo "release_pr_output: $release_pr_output"
prs=$(echo $release_pr_output | jq -c .prs)
Expand All @@ -138,12 +139,12 @@ runs:
then
echo "-- Running release-plz release --"
release_output=$(release-plz release\
--git-token ${GITHUB_TOKEN}\
${CONFIG_PATH}\
${ALT_REGISTRY}\
${MANIFEST_PATH}\
${BACKEND}\
${TOKEN}\
--git-token "${GITHUB_TOKEN}"\
"${CONFIG_PATH[@]}"\
"${ALT_REGISTRY[@]}"\
"${MANIFEST_PATH[@]}"\
"${BACKEND[@]}"\
"${TOKEN[@]}"\
-o json)
echo "release_output: $release_output"
releases=$(echo $release_output | jq -c .releases)
Expand Down