{"id":21471147,"url":"https://github.com/im-open/variable-substitution","last_synced_at":"2025-03-17T06:46:05.673Z","repository":{"id":251767521,"uuid":"637869786","full_name":"im-open/variable-substitution","owner":"im-open","description":"Enable GitHub developers to parameterize the values in their config files from a GitHub Action workflow","archived":false,"fork":false,"pushed_at":"2024-08-05T14:33:02.000Z","size":7648,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-23T16:14:53.361Z","etag":null,"topics":["infra-purple-team","meta","variables"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/im-open.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-08T15:26:36.000Z","updated_at":"2024-09-07T14:02:29.000Z","dependencies_parsed_at":"2024-08-05T16:54:15.685Z","dependency_job_id":null,"html_url":"https://github.com/im-open/variable-substitution","commit_stats":null,"previous_names":["im-open/variable-substitution"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/im-open%2Fvariable-substitution","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/im-open%2Fvariable-substitution/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/im-open%2Fvariable-substitution/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/im-open%2Fvariable-substitution/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/im-open","download_url":"https://codeload.github.com/im-open/variable-substitution/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243988959,"owners_count":20379649,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["infra-purple-team","meta","variables"],"created_at":"2024-11-23T09:31:55.286Z","updated_at":"2025-03-17T06:46:05.651Z","avatar_url":"https://github.com/im-open.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# variable-substitution\r\n\r\nThis Action is a copy of the deprecated [microsoft/variable-substitution] which has been updated to run on Node 16.\r\n\r\n## GitHub Action for substituting variables in parameterized files\r\n\r\nWith the variable-substitution Action for GitHub, you can apply variable substitution to XML, JSON and YAML based configuration and parameter files.\r\n\r\n- Tokens defined in the target configuration files are updated and then replaced with variable values.\r\n- Variable substitution is applied for only the JSON keys predefined in the object hierarchy. It does not create new keys.\r\n- 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.\r\n- Variable substitution takes effect only on the `applicationSettings`, `appSettings`, `connectionStrings` and `configSections` elements of configuration files. Please refer [this](https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/transforms-variable-substitution?view=azure-devops\u0026tabs=Classic#xml-variable-substitution) for more information.\r\n\r\nThe definition of this Github Action is in [action.yml](https://github.com/im-open/variable-substitution/blob/master/action.yml).\r\n\r\n## Inputs\r\n\r\n| Parameter | Is Required | Description                                                                                                                                   |\r\n|-----------|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------|\r\n| `files`   | true        | Comma separated list of XML/JSON/YAML files in which tokens are to be substituted. \u003cbr/\u003e\u003cbr/\u003eFiles names must be specified relative to the folder-path. |\r\n\r\n## Outputs\r\n\r\nThis action does not have outputs.\r\n\r\n### Usage Example\r\n\r\nSee [Use variable substitution with GitHub Actions](https://docs.microsoft.com/en-us/azure/developer/github/github-variable-substitution) for additional examples of how to use variable substitution.\r\n\r\n#### Configuration file before substitution\r\n\r\n```json\r\n{\r\n  \"IsProduction\": false,\r\n  \"ClientId\": 123456,\r\n  \"ConnectionStrings\": {\r\n    \"MyApp\": \"Server=localhost;Database=MyDB;Trusted_Connection=True\"\r\n  }\r\n}\r\n```\r\n\r\n#### Workflow that uses the action\r\n\r\n```yaml\r\non: [pull_request]\r\nname: CI Build\r\n\r\njobs:\r\n  run-integration-tests:\r\n    runs-on: ubuntu-latest\r\n    steps:\r\n    - uses: actions/checkout@v4\r\n\r\n    - name: Update sql connection string in test project\r\n      uses: im-open/variable-substitution@v2.1.0 #v2 or v2.1 can also be used\r\n      with:\r\n        files: './src/MyApp.Tests/appsettings.json'\r\n      env:\r\n        # Substitutions are case sensitive and must match what is present\r\n        # in the file with substitutions (in this case appsettings.json)\r\n        ClientId: 098765\r\n        ConnectionStrings.MyApp: 'Server=localhost;Database=MyDB;Trusted_Connection=False;User ID=SA;Password=Abc123!'\r\n\r\n    - name: run integration tests\r\n      run: dotnet test --no-restore --configuration Release\r\n ```\r\n\r\n#### Configuration file after substitution\r\n\r\n```json\r\n{\r\n  \"IsProduction\": false,\r\n  \"ClientId\": 098765,\r\n  \"ConnectionStrings\": {\r\n    \"MyApp\": \"Server=localhost;Database=MyDB;Trusted_Connection=False;User ID=SA;Password=Abc123!\"\r\n  }\r\n}\r\n```\r\n\r\n## Code of Conduct\r\n\r\nThis project has adopted the [im-open's Code of Conduct](https://github.com/im-open/.github/blob/main/CODE_OF_CONDUCT.md).\r\n\r\n## License\r\n\r\nCopyright \u0026copy; 2023, Extend Health, LLC. Code released under the [MIT license](LICENSE).\r\n\r\n[microsoft/variable-substitution]: https://github.com/microsoft/variable-substitution\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fim-open%2Fvariable-substitution","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fim-open%2Fvariable-substitution","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fim-open%2Fvariable-substitution/lists"}