This Action is a copy of the deprecated microsoft/variable-substitution which has been updated to run on Node 16.
With the variable-substitution Action for GitHub, you can apply variable substitution to XML, JSON and YAML based configuration and parameter files.
- Tokens defined in the target configuration files are updated and then replaced with variable values.
- Variable substitution is applied for only the JSON keys predefined in the object hierarchy. It does not create new keys.
- Only variables defined explicitly as Environment variables as part of the workflow or system variables that are already available for workflow context can be used in substitution.
- Variable substitution takes effect only on the
applicationSettings,appSettings,connectionStringsandconfigSectionselements of configuration files. Please refer this for more information.
The definition of this Github Action is in action.yml.
| Parameter | Is Required | Description |
|---|---|---|
files |
true | Comma separated list of XML/JSON/YAML files in which tokens are to be substituted. Files names must be specified relative to the folder-path. |
This action does not have outputs.
See Use variable substitution with GitHub Actions for additional examples of how to use variable substitution.
{
"IsProduction": false,
"ClientId": 123456,
"ConnectionStrings": {
"MyApp": "Server=localhost;Database=MyDB;Trusted_Connection=True"
}
}on: [pull_request]
name: CI Build
jobs:
run-integration-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Update sql connection string in test project
uses: im-open/[email protected] #v2 or v2.1 can also be used
with:
files: './src/MyApp.Tests/appsettings.json'
env:
# Substitutions are case sensitive and must match what is present
# in the file with substitutions (in this case appsettings.json)
ClientId: 098765
ConnectionStrings.MyApp: 'Server=localhost;Database=MyDB;Trusted_Connection=False;User ID=SA;Password=Abc123!'
- name: run integration tests
run: dotnet test --no-restore --configuration Release{
"IsProduction": false,
"ClientId": 098765,
"ConnectionStrings": {
"MyApp": "Server=localhost;Database=MyDB;Trusted_Connection=False;User ID=SA;Password=Abc123!"
}
}This project has adopted the im-open's Code of Conduct.
Copyright © 2023, Extend Health, LLC. Code released under the MIT license.