I'm developing a web API using .Net core 3.1 trying to integrate it to Github Actions to run the integration tests when a pull request is created.
I'm using the secrets manager to store my API tokens and other sensitive data in development mode
secrets.json
{
"Firebase": {
"Login": "foo@bar.com",
"Password": "FooBar",
"Url": "foobar.firebaseapp.com "
},
}
And on GitHub I've tried to add Secrets(GitHub secrets = environment variables) with the same names I have on my secrets JSON but it hasn't worked. The GitHub secrets that I've created are like
(KEY - VALUE)
LOGIN - foo@bar.com
PASSWORD - FooBar
And on my test class, I'm invoking the environment variables using the following configuration before the tests
public MyTestClass()
{
var builder = new ConfigurationBuilder()
.AddUserSecrets<MyTestClass>()
.AddEnvironmentVariables();
Configuration = builder.Build();
_settings = Configuration.Get<Settings>();
}
And my .yml looks like
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.300
- name: Nuget
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
env:
LOGIN: ${{ secrets.LOGIN }}
PASSWORD: ${{ secrets.PASSWORD}}
URL: ${{ secrets.URL}}
How can I load the Settings when executing inside GitHub Actions?