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: print correct tag #208

Merged
merged 1 commit into from
May 10, 2023
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
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")")
Copy link
Contributor

Choose a reason for hiding this comment

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

🔥

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