Skip to content

Commit 5ecdce8

Browse files
authored
docs: Refine OIDC docs (#1837)
* Refine OIDC docs and format * Unformat table
1 parent 15559ed commit 5ecdce8

File tree

1 file changed

+65
-45
lines changed

1 file changed

+65
-45
lines changed

README.md

Lines changed: 65 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@
33
[![GitHub Marketplace](https://img.shields.io/badge/Marketplace-v5-undefined.svg?logo=github&logoColor=white&style=flat)](https://github.com/marketplace/actions/codecov)
44
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fcodecov-action.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fcodecov-action?ref=badge_shield)
55
[![Workflow for Codecov Action](https://github.com/codecov/codecov-action/actions/workflows/main.yml/badge.svg)](https://github.com/codecov/codecov-action/actions/workflows/main.yml)
6+
67
### Easily upload coverage reports to Codecov from GitHub Actions
78

89
## v5 Release
10+
911
`v5` of the Codecov GitHub Action will use the [Codecov Wrapper](https://github.com/codecov/wrapper) to encapsulate the [CLI](https://github.com/codecov/codecov-cli). This will help ensure that the Action gets updates quicker.
1012

1113
### Migration Guide
14+
1215
The `v5` release also coincides with the opt-out feature for tokens for public repositories. In the `Global Upload Token` section of the settings page of an organization in codecov.io, you can set the ability for Codecov to receive a coverage reports from any source. This will allow contributors or other members of a repository to upload without needing access to the Codecov token. For more details see [how to upload without a token](https://docs.codecov.com/docs/codecov-tokens#uploading-without-a-token).
1316

14-
> [!WARNING]
15-
> **The following arguments have been changed**
17+
> [!WARNING] > **The following arguments have been changed**
18+
>
1619
> - `file` (this has been deprecated in favor of `files`)
1720
> - `plugin` (this has been deprecated in favor of `plugins`)
1821
@@ -30,13 +33,16 @@ The following arguments have been added:
3033
You can see their usage in the `action.yml` [file](https://github.com/codecov/codecov-action/blob/main/action.yml).
3134

3235
## v4 Release
36+
3337
`v4` of the Codecov GitHub Action will use the [Codecov CLI](https://github.com/codecov/codecov-cli) to upload coverage reports to Codecov.
3438

3539
### Breaking Changes
40+
3641
- Tokenless uploading is unsupported. However, PRs made from forks to the upstream public repos will support tokenless (e.g. contributors to OSS projects do not need the upstream repo's Codecov token). For details, [see our docs](https://docs.codecov.com/docs/codecov-uploader#supporting-token-less-uploads-for-forks-of-open-source-repos-using-codecov)
3742
- Various arguments to the Action have been removed
3843

3944
### Dependabot
45+
4046
- For repositories using `Dependabot`, users will need to ensure that it has access to the Codecov token for PRs from Dependabot to upload coverage. To do this, please add your `CODECOV_TOKEN` as a Dependabot Secret. For more information, see ["Configuring access to private registries for Dependabot."](https://docs.github.com/en/code-security/dependabot/working-with-dependabot/configuring-access-to-private-registries-for-dependabot#storing-credentials-for-dependabot-to-use)
4147

4248
`v3` versions and below will not have access to CLI features (e.g. global upload token, ATS).
@@ -51,6 +57,7 @@ To integrate Codecov with your Actions pipeline, specify the name of this reposi
5157
This Action also requires you to [provide an upload token](https://docs.codecov.io/docs/frequently-asked-questions#section-where-is-the-repository-upload-token-found-) from [codecov.io](https://www.codecov.io) (tip: in order to avoid exposing your token, [store it](https://docs.codecov.com/docs/adding-the-codecov-token#github-actions) as a `secret`).
5258

5359
Currently, the Action will identify linux, macos, and windows runners. However, the Action may misidentify other architectures. The OS can be specified as
60+
5461
- alpine
5562
- alpine-arm64
5663
- linux
@@ -62,37 +69,39 @@ Inside your `.github/workflows/workflow.yml` file:
6269

6370
```yaml
6471
steps:
65-
- uses: actions/checkout@main
66-
- uses: codecov/codecov-action@v5
67-
with:
68-
fail_ci_if_error: true # optional (default = false)
69-
files: ./coverage1.xml,./coverage2.xml # optional
70-
flags: unittests # optional
71-
name: codecov-umbrella # optional
72-
token: ${{ secrets.CODECOV_TOKEN }}
73-
verbose: true # optional (default = false)
72+
- uses: actions/checkout@main
73+
- uses: codecov/codecov-action@v5
74+
with:
75+
fail_ci_if_error: true # optional (default = false)
76+
files: ./coverage1.xml,./coverage2.xml # optional
77+
flags: unittests # optional
78+
name: codecov-umbrella # optional
79+
token: ${{ secrets.CODECOV_TOKEN }}
80+
verbose: true # optional (default = false)
7481
```
7582
7683
The Codecov token can also be passed in via environment variables:
7784
7885
```yaml
7986
steps:
80-
- uses: actions/checkout@main
81-
- uses: codecov/codecov-action@v5
82-
with:
83-
fail_ci_if_error: true # optional (default = false)
84-
files: ./coverage1.xml,./coverage2.xml # optional
85-
flags: unittests # optional
86-
name: codecov-umbrella # optional
87-
verbose: true # optional (default = false)
88-
env:
89-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
87+
- uses: actions/checkout@main
88+
- uses: codecov/codecov-action@v5
89+
with:
90+
fail_ci_if_error: true # optional (default = false)
91+
files: ./coverage1.xml,./coverage2.xml # optional
92+
flags: unittests # optional
93+
name: codecov-umbrella # optional
94+
verbose: true # optional (default = false)
95+
env:
96+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
9097
```
98+
9199
> [!NOTE]
92-
> This assumes that you've set your Codecov token inside *Settings > Secrets* as `CODECOV_TOKEN`. If not, you can [get an upload token](https://docs.codecov.io/docs/frequently-asked-questions#section-where-is-the-repository-upload-token-found-) for your specific repo on [codecov.io](https://www.codecov.io). Keep in mind that secrets are *not* available to forks of repositories.
100+
> This assumes that you've set your Codecov token inside _Settings > Secrets_ as `CODECOV_TOKEN`. If not, you can [get an upload token](https://docs.codecov.io/docs/frequently-asked-questions#section-where-is-the-repository-upload-token-found-) for your specific repo on [codecov.io](https://www.codecov.io). Keep in mind that secrets are _not_ available to forks of repositories.
93101

94102
### Using OIDC
95-
For users with [OpenID Connect(OIDC) enabled](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect), the Codecov token is not necessary. You can use OIDC with the `use_oidc` argument as following.
103+
104+
As an alternative to Codecov upload tokens, you can choose to use OIDC as your upload authentication method by setting the `use_oidc` argument:
96105

97106
```yaml
98107
- uses: codecov/codecov-action@v5
@@ -102,6 +111,16 @@ For users with [OpenID Connect(OIDC) enabled](https://docs.github.com/en/actions
102111

103112
Any token supplied will be ignored, as Codecov will default to the OIDC token for verification.
104113

114+
Note that the codecov action must have write permission for `id-token` for this to work:
115+
116+
```yaml
117+
permissions:
118+
id-token: write
119+
```
120+
121+
This can be set at either the workflow or job level. See GitHub's [docs](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-
122+
openid-connect) for more details.
123+
105124
## Arguments
106125

107126
Codecov's Action supports inputs from the user. These inputs, along with their descriptions and usage contexts, are listed in the table below:
@@ -171,30 +190,31 @@ jobs:
171190
os: [ubuntu-latest, macos-latest, windows-latest]
172191
env:
173192
OS: ${{ matrix.os }}
174-
PYTHON: '3.10'
193+
PYTHON: "3.10"
175194
steps:
176-
- uses: actions/checkout@main
177-
- name: Setup Python
178-
uses: actions/setup-python@main
179-
with:
180-
python-version: '3.10'
181-
- name: Generate coverage report
182-
run: |
183-
pip install pytest
184-
pip install pytest-cov
185-
pytest --cov=./ --cov-report=xml
186-
- name: Upload coverage to Codecov
187-
uses: codecov/codecov-action@v5
188-
with:
189-
directory: ./coverage/reports/
190-
env_vars: OS,PYTHON
191-
fail_ci_if_error: true
192-
files: ./coverage1.xml,./coverage2.xml,!./cache
193-
flags: unittests
194-
name: codecov-umbrella
195-
token: ${{ secrets.CODECOV_TOKEN }}
196-
verbose: true
195+
- uses: actions/checkout@main
196+
- name: Setup Python
197+
uses: actions/setup-python@main
198+
with:
199+
python-version: "3.10"
200+
- name: Generate coverage report
201+
run: |
202+
pip install pytest
203+
pip install pytest-cov
204+
pytest --cov=./ --cov-report=xml
205+
- name: Upload coverage to Codecov
206+
uses: codecov/codecov-action@v5
207+
with:
208+
directory: ./coverage/reports/
209+
env_vars: OS,PYTHON
210+
fail_ci_if_error: true
211+
files: ./coverage1.xml,./coverage2.xml,!./cache
212+
flags: unittests
213+
name: codecov-umbrella
214+
token: ${{ secrets.CODECOV_TOKEN }}
215+
verbose: true
197216
```
217+
198218
## Contributing
199219

200220
Contributions are welcome! Check out the [Contribution Guide](CONTRIBUTING.md).

0 commit comments

Comments
 (0)