Skip to content

Commit 91ee72e

Browse files
committed
Replace hard-coded codecov_token with secrets/variables
1 parent e95eb88 commit 91ee72e

File tree

4 files changed

+9
-16
lines changed

4 files changed

+9
-16
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ on:
1212
env:
1313
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
1414
BUILDCONFIGURATION: Release
15-
# codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/
1615
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages/
1716

1817
jobs:
@@ -64,11 +63,13 @@ jobs:
6463
uses: ./.github/actions/publish-artifacts
6564
if: cancelled() == false
6665
- name: 📢 Publish code coverage results to codecov.io
67-
run: ./tools/publish-CodeCov.ps1 -CodeCovToken "${{ env.codecov_token }}" -PathToCodeCoverage "${{ runner.temp }}/_artifacts/coverageResults" -Name "${{ runner.os }} Coverage Results" -Flags "${{ runner.os }}"
66+
run: |
67+
if ('${{ secrets.CODECOV_TOKEN }}') {
68+
./tools/publish-CodeCov.ps1 -CodeCovToken '${{ secrets.CODECOV_TOKEN }}' -PathToCodeCoverage "${{ runner.temp }}/_artifacts/coverageResults" -Name "${{ runner.os }} Coverage Results" -Flags "${{ runner.os }}"
69+
}
6870
shell: pwsh
6971
timeout-minutes: 3
7072
continue-on-error: true
71-
if: env.codecov_token != ''
7273

7374
docs:
7475
name: 📃 Docs

Expand-Template.ps1

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ Expands this template into an actual project, taking values for placeholders
77
The name of the library. Should consist only of alphanumeric characters and periods.
88
.PARAMETER Author
99
The name to use in copyright and owner notices.
10-
.PARAMETER CodeCovToken
11-
A token obtained from codecov.io for your repo. If not specified, code coverage results will not be published to codecov.io,
12-
but can be added later by editing the Azure Pipelines YAML file.
1310
.PARAMETER CIFeed
1411
The `/{guid}` path to the Azure Pipelines artifact feed to push your nuget package to as part of your CI.
1512
.PARAMETER Squash
@@ -22,8 +19,6 @@ Param(
2219
[Parameter(Mandatory=$true)]
2320
[string]$Author,
2421
[Parameter()]
25-
[string]$CodeCovToken,
26-
[Parameter()]
2722
[string]$CIFeed,
2823
[Parameter()]
2924
[switch]$Squash
@@ -179,11 +174,6 @@ try {
179174
}
180175

181176
$YmlReplacements = @{}
182-
if ($CodeCovToken) {
183-
$YmlReplacements['(codecov_token: ).*(#.*)'] = "`$1$CodeCovToken"
184-
} else {
185-
$YmlReplacements['(codecov_token: ).*(#.*)'] = "#`$1`$2"
186-
}
187177
if ($CIFeed) {
188178
$YmlReplacements['(ci_feed: ).*(#.*)'] = "`$1$CIFeed"
189179
} else {

azure-pipelines.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ parameters:
2626
variables:
2727
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
2828
BuildConfiguration: Release
29-
codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/
3029
ci_feed: https://pkgs.dev.azure.com/andrewarnott/_packaging/CI/nuget/v3/index.json # Azure Artifacts feed URL
3130
NUGET_PACKAGES: $(Agent.TempDirectory)/.nuget/packages/
3231

azure-pipelines/dotnet.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ steps:
2020
displayName: 📢 Publish artifacts
2121
condition: succeededOrFailed()
2222

23-
- ${{ if and(ne(variables['codecov_token'], ''), parameters.RunTests) }}:
23+
- ${{ if parameters.RunTests }}:
2424
- powershell: |
2525
$ArtifactStagingFolder = & "tools/Get-ArtifactsStagingDirectory.ps1"
2626
$CoverageResultsFolder = Join-Path $ArtifactStagingFolder "coverageResults-$(Agent.JobName)"
27-
tools/publish-CodeCov.ps1 -CodeCovToken "$(codecov_token)" -PathToCodeCoverage "$CoverageResultsFolder" -Name "$(Agent.JobName) Coverage Results" -Flags "$(Agent.JobName)"
27+
tools/publish-CodeCov.ps1 -CodeCovToken "$(CODECOV_TOKEN)" -PathToCodeCoverage "$CoverageResultsFolder" -Name "$(Agent.JobName) Coverage Results" -Flags "$(Agent.JobName)"
2828
displayName: 📢 Publish code coverage results to codecov.io
2929
timeoutInMinutes: 3
3030
continueOnError: true
31+
# Set the CODECOV_TOKEN variable in your Azure Pipeline to enable code coverage reporting
32+
# Get a token from https://codecov.io/
33+
condition: and(succeeded(), ne(variables['CODECOV_TOKEN'], ''))

0 commit comments

Comments
 (0)