* Store the bundle sizes for a commit hash in the build artifacts storage * repository to the passed value. * @return {Promise }
()
| 98 | * @return {Promise<void>} |
| 99 | */ |
| 100 | async function storeBundleSize() { |
| 101 | if (!isPushBuild() || ciPushBranch() !== 'main') { |
| 102 | log( |
| 103 | yellow('Skipping'), |
| 104 | cyan('--on_push_build') + ':', |
| 105 | 'this action can only be performed on main branch push builds during CI' |
| 106 | ); |
| 107 | return; |
| 108 | } |
| 109 | |
| 110 | if (ciRepoSlug() !== expectedGitHubRepoSlug) { |
| 111 | log( |
| 112 | yellow('Skipping'), |
| 113 | cyan('--on_push_build') + ':', |
| 114 | 'this action can only be performed during CI builds on the', |
| 115 | cyan(expectedGitHubRepoSlug), |
| 116 | 'repository' |
| 117 | ); |
| 118 | return; |
| 119 | } |
| 120 | |
| 121 | const commitHash = gitCommitHash(); |
| 122 | log('Storing bundle sizes for commit', cyan(shortSha(commitHash)) + '...'); |
| 123 | try { |
| 124 | const response = await postJson( |
| 125 | url.resolve( |
| 126 | bundleSizeAppBaseUrl, |
| 127 | path.join('commit', commitHash, 'store') |
| 128 | ), |
| 129 | { |
| 130 | token: process.env.BUNDLE_SIZE_TOKEN, |
| 131 | bundleSizes: await getBrotliBundleSizes(), |
| 132 | } |
| 133 | ); |
| 134 | await checkResponse(response, 'Successfully stored bundle sizes.'); |
| 135 | } catch (error) { |
| 136 | log(yellow('WARNING:'), 'Could not store bundle sizes'); |
| 137 | logWithoutTimestamp(error); |
| 138 | return; |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Mark a pull request as skipped, via the AMP bundle-size GitHub App. |
no test coverage detected