Skip to content

Commit 6e8d406

Browse files
Protect GitHub Actions secrets via local environment variables
1 parent 15c325f commit 6e8d406

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

.github/workflows/Sonar.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ jobs:
3030
run: dotnet restore
3131

3232
- name: Start Sonar Analysis
33-
run: dotnet-sonarscanner begin /d:sonar.host.url="https://sonarcloud.io" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /o:"ecoapm" /k:"ecoAPM_dotnet-libyear" /d:sonar.cs.vstest.reportsPaths="test/**/results.trx" /d:sonar.cs.opencover.reportsPaths="test/**/coverage.opencover.xml"
33+
run: dotnet-sonarscanner begin /d:sonar.host.url="https://sonarcloud.io" /d:sonar.login="$SONAR_TOKEN" /o:"ecoapm" /k:"ecoAPM_dotnet-libyear" /d:sonar.cs.vstest.reportsPaths="test/**/results.trx" /d:sonar.cs.opencover.reportsPaths="test/**/coverage.opencover.xml"
34+
env:
35+
SONAR_TOKEN: ${{secrets.SONAR_TOKEN}}
3436

3537
- name: Build
3638
run: dotnet build --no-restore
@@ -41,6 +43,7 @@ jobs:
4143
run: dotnet test --no-build --logger "trx;LogFileName=results.trx" --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
4244

4345
- name: Finish Sonar Analysis
44-
run: dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
46+
run: dotnet-sonarscanner end /d:sonar.login="$SONAR_TOKEN"
4547
env:
48+
SONAR_TOKEN: ${{secrets.SONAR_TOKEN}}
4649
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/nuget.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ jobs:
2323
run: dotnet pack -c Release -p:ContinuousIntegrationBuild=true
2424

2525
- name: Publish app
26-
run: dotnet nuget push src/LibYear/bin/Release/LibYear.$(echo ${{ github.ref }} | sed 's/refs\/tags\///').nupkg -k ${{ secrets.NUGET_TOKEN }} -s https://api.nuget.org/v3/index.json
26+
run: dotnet nuget push src/LibYear/bin/Release/LibYear.$(echo ${{ github.ref }} | sed 's/refs\/tags\///').nupkg -k $NUGET_TOKEN -s https://api.nuget.org/v3/index.json
27+
env:
28+
NUGET_TOKEN: ${{secrets.NUGET_TOKEN}}
2729

2830
- name: Publish library
29-
run: dotnet nuget push src/LibYear.Core/bin/Release/LibYear.Core.$(echo ${{ github.ref }} | sed 's/refs\/tags\///').nupkg -k ${{ secrets.NUGET_TOKEN }} -s https://api.nuget.org/v3/index.json
31+
run: dotnet nuget push src/LibYear.Core/bin/Release/LibYear.Core.$(echo ${{ github.ref }} | sed 's/refs\/tags\///').nupkg -k $NUGET_TOKEN -s https://api.nuget.org/v3/index.json

0 commit comments

Comments
 (0)