This action will scan the file(s) provided in the files-with-substitutions
argument for Octopus variable substitution syntax #{VariableName}
. If the files contain any #{Variables}
that match an item in the variables-file
or environment variables, it will replace the template with the actual value. If a variable is found in both the variables-file
and in the environment variables, then the environment variable value will be used.
Some items to note:
- This action will make modifications to any files in
files-with-substitutions
if matching Octostache templates are identified. - Substitutions can be defined in a
variables-file
or as environment variables.- The action will use default GitHub environment variables and environments variables set at the workflow, job or step level.
- The action does not consider case when looking for Octostache templates to replace. For example if a one of the files with substitutions contained
${launchdarkly}
and an env var was defined asLAUNCHDARKLY
, the substitution would be made.
Parameter | Is Required | Description |
---|---|---|
variables-file |
false | An optional yaml file containing variables to use in the substitution. The alternative is to define environment variables to use for the substitutions. |
files-with-substitutions |
true | A comma separated list of files or .NET-compatible glob patterns with #{variables} that need substitution. |
No Outputs
When using the variables-file
argument, this is the structure of the file containing the variable names and values that will be substituted.
Environment: Dev
Version: 1.3.62
LaunchDarklyKey: abc
GoogleAnalyticsKey: 123
AppInsightsKey: a1b2c3
In addition to the variables-file
argument, substitutions can be provided in the env:
section of the action. The format matches what is supplied in the variables-file
: <var-name>: <var-value>
.
If the same item is provided in the variables-file
and the env:
section, the value in the env:
section will be used.
These are some sample files that contain the Octostache substitution syntax #{}
. These files would be included in the files-with-substitutions
argument above.
DemoApp19.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<Version>#{VersionToReplace}</Version>
</PropertyGroup>
</Project>
build-variables.js
const { profiles } = require('../../Properties/launchSettings.json');
const { environmentTypes } = require('./constants');
const substitutionVariables = {
BUILD_APPINSIGHTS_INSTRUMENTATION_KEY: '#{AppInsightsKey}',
BUILD_GA_KEY: '#{GoogleAnalyticsKey}',
BUILD_LAUNCH_DARKLY_KEY: '#{LaunchDarklyKey}}'
};
index.html
<html>
<head>
<!--... head items ...-->
<script type="text/javascript">var gaKey = '#{GoogleAnalyticsKey}';</script>
</head>
<body>
<!--... application body ...-->
</body>
</html>
name: Deploy
on:
workflow_dispatch:
jobs:
substitute-variables:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
# You may also reference just the major or major.minor version
- uses: im-open/octostache-action@v4.0.3
with:
variables-file: