I am struggling to replace values in my appsettings.json
file and was wondering where I'm going wrong?
I have created two secrets in GitHub entitled COSMOSDBSETTINGS_SERVICEENDPOINT
and COSMOSDBSETTINGS_AUTHKEY
.
- name: Publish
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp
- name: App Settings Variable Substitution
uses: microsoft/variable-substitution@v1
with:
files: '${{env.DOTNET_ROOT}}\myapp\appsettings.json'
env:
CosmosDbSettings:ServiceEndpoint: ${{ secrets.COSMOSDBSETTINGS_SERVICEENDPOINT }}
CosmosDbSettings:AuthKey: ${{ secrets.COSMOSDBSETTINGS_AUTHKEY }}
I get the error stating
Run microsoft/variable-substitution@v1
Applying variable substitution on JSON file: C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\myapp\appsettings.json
Skipped updating file: C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\myapp\appsettings.json
Error: Error: Failed to apply variable substitution
This is the appsettings
locally:
"CosmosDbSettings": {
"ServiceEndpoint": "https://localhost:8081/",
"AuthKey": "KEY"
},
Use a dot instead of a colon:
env:
CosmosDbSettings.ServiceEndpoint: ${{ secrets.COSMOSDBSETTINGS_SERVICEENDPOINT }}
CosmosDbSettings.AuthKey: ${{ secrets.COSMOSDBSETTINGS_AUTHKEY }}