What specifically needs to change in the -f body=$DESCRIPTION
flag of the gh api
CLI command in the GitHub workflow below
in order for a multi-word string such as "Lots of new stuff"
to successfully be passed into the description of the
resulting GitHub release?
The problem we are currently having is that the "Lots of new stuff"
string results in an error stating that the body
expects 1 argument but received 4.
When we pass a single-word string into the same workflow, it runs successfully without error.
When we change the body
flag to read -f body='$DESCRIPTION'
, the resulting description for the release is rendered as $DESCRIPTION
.
WORKFDLOW CODE:
name: release-manually
on:
workflow_dispatch:
inputs:
version:
description: 'Version'
required: true
type: string
description:
description: 'Description of release'
required: true
type: string
jobs:
release-a-version:
runs-on: ubuntu-latest
steps:
- shell: bash
name: Release
env:
DESCRIPTION: ${{ inputs.description }}
VERSION: ${{ inputs.version }}
GH_TOKEN: ${{ secrets.GIT_PAT }}
run: |
vers="_linux_"$VERSION
echo "About to print version"
echo $vers
nameOfRelease="release_name"$vers
echo "About to print name of release"
echo $nameOfRelease
echo "About to create release"
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
/repos/AccountName/RepoName/releases \
-f tag_name=$vers \
-f target_commitish='branch-name' \
-f name=$nameOfRelease \
-f body=$DESCRIPTION \
-F draft=false \
-F prerelease=false \
-F generate_release_notes=false
-H "Accept: application/vnd.github+json"
line, I would try them around the value you're asking about:-f body="$DESCRIPTION"
. Shells will expand"$DESCRIPTION"
(wrapped in double-quotes) where they won't expand'$DESCRIPTION'
(wrapped in single-quotes) – Sotto Voce Sep 08 '22 at 20:43