Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion lib/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ set_release_secrets() {

gh secret set RELEASE_APP_ID --repo "$slug" --body "$RELEASE_APP_ID" >/dev/null ||
die "could not set RELEASE_APP_ID on ${slug}"
gh secret set RELEASE_APP_PRIVATE_KEY --repo "$slug" --body "$RELEASE_APP_PRIVATE_KEY" >/dev/null ||
# On stdin: argv is visible to every user on the host.
printf '%s' "$RELEASE_APP_PRIVATE_KEY" |
gh secret set RELEASE_APP_PRIVATE_KEY --repo "$slug" >/dev/null ||
die "could not set RELEASE_APP_PRIVATE_KEY on ${slug}"
}
17 changes: 16 additions & 1 deletion tests/publish.bats
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ case "$1 $2" in
[ "${GH_SCENARIO}" = absent ] && exit 1
printf '{"name":"demo"}\n'; exit 0 ;;
"repo create") exit 0 ;;
"secret set") exit 0 ;;
"secret set")
[[ "$*" == *--body* ]] || cat >>"${GH_LOG}.stdin"
exit 0 ;;
esac

# `gh api repos/<slug>/rulesets` with no -X is the listing; with -X POST it is
Expand Down Expand Up @@ -252,6 +254,19 @@ _project() {
[ "$output" = 2 ]
}

@test "the release app private key reaches gh on stdin, never on argv" {
_stub_gh
_project

GH_SCENARIO=exists RELEASE_APP_ID=1 RELEASE_APP_PRIVATE_KEY=k3y-s3cret \
run scaffold publish "$PROJECT"
assert_ok
run grep -c 'k3y-s3cret' "$GH_LOG"
[ "$output" = 0 ]
run cat "${GH_LOG}.stdin"
[[ "$output" == *k3y-s3cret* ]]
}

@test "the ruleset it posts is valid json and carries the three rules" {
# The payload is a heredoc, so a typo in it reaches GitHub as a 422 on
# somebody's real repository rather than as a failure here.
Expand Down