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

Upgrade to Node v18, fix deploy-preview CI job #236

Merged
merged 6 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
update comment body
  • Loading branch information
adidahiya committed Oct 20, 2023
commit f2f67aefa0c19faf8120d5bcf160da4a8c41e21b
10 changes: 3 additions & 7 deletions scripts/submit-comment-with-artifact-links.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ if (artifacts.items === undefined) {
}

const ARTIFACTS = {
documentation: "packages/docs-app/dist/index.html",
landing: "packages/landing-app/dist/index.html",
table: "packages/table-dev-app/dist/index.html",
demo: "packages/demo-app/dist/index.html",
documentation: "packages/docs/dist/index.html",
};

function getArtifactAnchorLink(pkg) {
Expand All @@ -43,14 +40,13 @@ if (process.env.GITHUB_API_TOKEN) {
// See https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-fine-grained-personal-access-token
const octokit = new Octokit({ auth: process.env.GITHUB_API_TOKEN });

const artifactLinks = Object.keys(ARTIFACTS).map(getArtifactAnchorLink).join(" | ");
const mainDocumentationLink = getArtifactAnchorLink("documentation");
const currentGitCommitMessage = execSync('git --no-pager log --pretty=format:"%s" -1')
.toString()
.trim()
.replace(/\\"/g, '\\\\"');
const commentBody = dedent`
<h3>${currentGitCommitMessage}</h3>
Build artifact links for this commit: <strong>${artifactLinks}</strong>
Build preview link for commit "${currentGitCommitMessage}": <strong>${mainDocumentationLink}</strong>

<em>This is an automated comment from the deploy-preview CircleCI job.</em>
`;
Expand Down
1 change: 1 addition & 0 deletions scripts/submit-preview-comment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if [ -z "${CIRCLE_API_TOKEN}" ]; then
fi

SCRIPTS_DIR=$(dirname "$(readlink -f "$0")")
# See https://circleci.com/docs/api/v2/index.html#operation/getJobArtifacts
artifacts=$(curl --request GET --url "https://circleci.com/api/v2/project/gh/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/$CIRCLE_BUILD_NUM/artifacts" --header "authorization: $CIRCLE_API_TOKEN")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

adjusted this based on docs: https://circleci.com/docs/api/v2/index.html#operation/getJobArtifacts

I'm thinking of migrating this to be completely implemented in JS and exporting it for re-use from @blueprintjs/node-build-scripts


echo $artifacts > ./scripts/artifacts.json
Expand Down