Environment Specific Requirements
Cloudflare Pages & Netlify
Cloudflare Pages does not automatically provide the repository slug to the environment variables, so you will need to manually set that in your plugin configuration through the upload overrides:
uploadOverrides: {
slug: "<enter your repo slug here - example: octocat/Hello-World>
}
GitHub Actions
Please ensure that in your workflow action that you have your actions/checkout
step set with a fetch depth > 1 or set it to 0, this will ensure that we are able to determine the correct commit SHA in the case of a merge commit.
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
An alternative to increasing fetch depth, is grabbing the SHA from the GHA event context, and passing it through as an upload override. Here is an example of setting the value as a env var:
- name: Build application
# ...
env:
GH_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
And here are the changes you would make to your Codecov plugin config:
codecovWebpackPlugin({
enableBundleAnalysis: true,
bundleName: '<bundle name>',
uploadToken: CODECOV_TOKEN,
uploadOverrides: {
sha: GH_COMMIT_SHA,
}
})
Vercel
To use Vercel with the bundle analysis plugins you will need to enable Automatically exposing System Environment Variables
option, which will expose a couple of Git values that Codecov requires.
You can read more about this on the Vercel docs.
Updated about 2 months ago