Skip to content

Commit 72a0c55

Browse files
authored
use field flag for file reference (#6)
1 parent df823a5 commit 72a0c55

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

scripts/init.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,14 @@ collapse_older_pipelines_notes() {
8383
if [[ "$note_body" =~ "<details open>" ]]; then
8484
echo "Removing open directive from note body"
8585
collapsed_body=$(sed 's/<details open>/<details>/' <<<"$note_body")
86-
glab api "projects/$CI_PROJECT_ID/merge_requests/$merge_request_id/notes/$note_id" --method PUT --raw-field "body=$collapsed_body" --silent
86+
# Write the content to a file to prevent going over the command line length capacity
87+
cat >/tmp/note_body.txt <<EOF
88+
$collapsed_body
89+
EOF
90+
91+
# Use the --field flag combined with the @ syntax to pass the file content as the body
92+
glab api "projects/$CI_PROJECT_ID/merge_requests/$merge_request_id/notes/$note_id" --method PUT --field "body=@/tmp/note_body.txt" --silent
93+
rm -f /tmp/note_body.txt
8794
fi
8895
fi
8996
done <<<"$notes_to_collapse"
@@ -127,7 +134,7 @@ credentials_log=$(mktemp -t pipelines-credentials-XXXXXXXX.log)
127134
get_gruntwork_read_token() {
128135
export PIPELINES_TOKEN_PATH="pipelines-read/gruntwork-io"
129136
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
130-
node "$SCRIPT_DIR/pipelines-credentials.mjs" > "$credentials_log" 2>&1
137+
node "$SCRIPT_DIR/pipelines-credentials.mjs" >"$credentials_log" 2>&1
131138
# The node script writes the token to a file, so we need to source it to make it available
132139
set -a
133140
source credentials.sh
@@ -162,7 +169,7 @@ clone_log=$(mktemp -t pipelines-clone-XXXXXXXX.log)
162169
set +e
163170
git clone -b "$GRUNTWORK_PIPELINES_ACTIONS_REF" \
164171
"https://oauth2:$PIPELINES_GRUNTWORK_READ_TOKEN@github.com:/gruntwork-io/pipelines-gitlab-actions.git" /tmp/pipelines-actions \
165-
> "$clone_log" 2>&1
172+
>"$clone_log" 2>&1
166173
clone_exit_code=$?
167174
set -e
168175

@@ -173,12 +180,11 @@ if [[ $clone_exit_code -ne 0 ]]; then
173180
fi
174181
echo "done."
175182

176-
177183
echo -n "Installing Pipelines CLI... "
178184
# Install the Pipelines CLI
179185
install_log=$(mktemp -t pipelines-install-XXXXXXXX.log)
180186
set +e
181-
/tmp/pipelines-actions/scripts/install-pipelines.sh > "$install_log" 2>&1
187+
/tmp/pipelines-actions/scripts/install-pipelines.sh >"$install_log" 2>&1
182188
install_exit_code=$?
183189
set -e
184190

0 commit comments

Comments
 (0)