在 appsettings.json GitHub Actions 中更改配置值

Change config values in appsettings.json GitHubActions

我正在努力替换我的 appsettings.json 文件中的值,想知道我哪里出错了?

我在 GitHub 中创建了两个名为 COSMOSDBSETTINGS_SERVICEENDPOINTCOSMOSDBSETTINGS_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 }}

我收到错误说明

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

这是本地的appsettings

  "CosmosDbSettings": {
    "ServiceEndpoint": "https://localhost:8081/",
    "AuthKey": "KEY"
  },

使用点代替冒号:

env:
  CosmosDbSettings.ServiceEndpoint: ${{ secrets.COSMOSDBSETTINGS_SERVICEENDPOINT }}
  CosmosDbSettings.AuthKey: ${{ secrets.COSMOSDBSETTINGS_AUTHKEY }}