Skip to content

Commit

Permalink
fix: print correct tag (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleTryon authored May 10, 2023
1 parent 14b0f45 commit 2dd2070
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions .circleci/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ workflows:
orb_name: circleci/orb-tools
vcs_type: <<pipeline.project.type>>
pub_type: dev
github_token: GHI_TOKEN
requires:
[orb-tools-alpha/lint, orb-tools-alpha/review, orb-tools-alpha/pack]
context: orb-publisher
Expand Down
12 changes: 7 additions & 5 deletions src/scripts/comment-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function postGitHubPRComment() {
-s \
-o /tmp/orb_dev_kit/github_comment_response.json \
-w "%{http_code}" \
--url "$ORB_PARAM_GH_GRAPHQL_URL" \
--url "$ORB_VAL_GH_GRAPHQL_URL" \
--header "$GH_HEADER_DATA" \
--data '{"query":"mutation AddCommentToPR($body: String!, $sid: ID!) {\n addComment(input: {\n body: $body,\n subjectId: $sid\n }) {\n clientMutationId\n }\n}","variables":{"body":"'"$PR_COMMENT_BODY"'","sid":"'"$1"'"},"operationName":"AddCommentToPR"}')
if [[ "$HTTP_RESPONSE_GH" -ne 200 || "$(jq '.errors | length' /tmp/orb_dev_kit/github_comment_response.json)" -gt 0 ]]; then
Expand All @@ -24,24 +24,26 @@ function postGitHubPRComment() {
function getGithubPRFromCommit() {
curl --request POST \
-s \
--url "$ORB_PARAM_GH_GRAPHQL_URL" \
--url "$ORB_VAL_GH_GRAPHQL_URL" \
--header "$GH_HEADER_DATA" \
--data '{"query":"query SearchForPR($query: String!) {\n search(query: $query, type: ISSUE, first: 3) {\n issueCount\n edges {\n node {\n ... on PullRequest {\n \tid\n title\n number\n }\n }\n }\n }\n}","variables":{"query":"'"$CIRCLE_SHA1"' is:pr"},"operationName":"SearchForPR"}'
}

function isAuthenticatedGitHub() {
curl --request POST \
-s \
--url "$ORB_PARAM_GH_GRAPHQL_URL" \
--url "$ORB_VAL_GH_GRAPHQL_URL" \
--header "$GH_HEADER_DATA" \
--data '{"query":"query IsAuthenticated {\n viewer {\n login\n }\n}","variables":{},"operationName":"IsAuthenticated"}'
}

function mainGitHub() {
echo "Checking if authenticated to GitHub..."
if [[ "$(isAuthenticatedGitHub | jq -e '.data.viewer.login')" != "null" ]]; then
local authenticated_user
authenticated_user="$(isAuthenticatedGitHub | jq -r '.data.viewer.login')"
if [[ "$authenticated_user" != "null" && -n "$authenticated_user" ]]; then
echo "Authenticated!"
echo "Authenticated as: $(isAuthenticatedGitHub | jq -r '.data.viewer.login')"
echo "Authenticated as: $authenticated_user"
FetchedPRData="$(getGithubPRFromCommit)"
# Fetch the PR ID from the commit
if [ "$(echo "$FetchedPRData" | jq -e '.data.search.issueCount')" -gt 0 ]; then
Expand Down
11 changes: 8 additions & 3 deletions src/scripts/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,23 @@ function publishOrb() {

function publishDevOrbs() {
printf "Publishing development orb(s).\n\n"
ORB_REG_LINKS=()
DEV_TAG_LIST=$(echo "${ORB_VAL_DEV_TAGS}" | tr -d ' ')
IFS=',' read -ra array <<<"$DEV_TAG_LIST"
for tag in "${array[@]}"; do
publishOrb "$tag"
# shellcheck disable=SC2005
PROCESSED_TAG=$(circleci env subst "$tag")
ORB_REG_LINKS+=("$(printf 'https://circleci.com/developer/orbs/orb/%s?version=%s' "$ORB_VAL_ORB_NAME" "$PROCESSED_TAG")")
publishOrb "$PROCESSED_TAG"
done
{
printf "Your development orb(s) have been published. It will expire in 30 days.\n"
printf "You can preview what this will look like on the CircleCI Orb Registry at the following link: \n"
printf "https://circleci.com/developer/orbs/orb/%s?version=dev:%s\n" "${ORB_VAL_ORB_NAME}" "${array[0]}"
printf "You can preview what this will look like on the CircleCI Orb Registry at the following link(s): \n"
printf "%s\n" "${ORB_REG_LINKS[@]}"
} >/tmp/orb_dev_kit/publishing_message.txt
}


# The main function
function orbPublish() {
printf "Preparing to publish your orb.\n"
Expand Down

0 comments on commit 2dd2070

Please sign in to comment.