-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Comment on PR with link to PR artifact
Summary: Changelog: [Internal] Configure circleCI to comment on PR after building tarball Reviewed By: hramos Differential Revision: D31387660 fbshipit-source-id: 28902148cf5e2ea15320333b90a6a7fa9d553c3b
- Loading branch information
1 parent
aae9355
commit 2a605c3
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const {GITHUB_TOKEN, CIRCLE_BUILD_URL, GITHUB_SHA} = process.env; | ||
if (!GITHUB_TOKEN || !CIRCLE_BUILD_URL) { | ||
if (!GITHUB_TOKEN) { | ||
console.error("Missing GITHUB_TOKEN. This should've been set by the CI."); | ||
} | ||
if (!CIRCLE_BUILD_URL) { | ||
console.error( | ||
"Missing CIRCLE_BUILD_URL. This should've been set by the CI.", | ||
); | ||
} | ||
process.exit(1); | ||
} | ||
|
||
const {createOrUpdateComment} = require('./make-comment'); | ||
|
||
/** | ||
* Creates or updates a comment with specified pattern. | ||
* @param {string} buildURL link to circleCI build | ||
* @param {string} commitSha github sha of PR | ||
*/ | ||
function postArtifactLink(buildUrl, commitSha) { | ||
const artifactLink = buildUrl + '/artifacts'; | ||
const comment = [ | ||
`PR build artifact${ | ||
commitSha != null ? ` for ${commitSha}` : '' | ||
} is ready.`, | ||
`To use, download tarball from [this CircleCI job](${artifactLink}) then run \`yarn add <path to tarball>\` in your React Native project.`, | ||
].join('\n'); | ||
createOrUpdateComment(comment); | ||
} | ||
|
||
try { | ||
postArtifactLink(CIRCLE_BUILD_URL, GITHUB_SHA); | ||
} catch (error) { | ||
console.error(error); | ||
process.exitCode = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
# Copyright (c) Facebook, Inc. and its affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
GITHUB_OWNER=${CIRCLE_PROJECT_USERNAME:-facebook} \ | ||
GITHUB_REPO=${CIRCLE_PROJECT_REPONAME:-react-native} \ | ||
GITHUB_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}" \ | ||
GITHUB_SHA=${CIRCLE_SHA1} \ | ||
exec node bots/post-artifacts-link.js |