Git Product home page Git Product logo

octostache-action's Introduction

octostache-action

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 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 as LAUNCHDARKLY, the substitution would be made.

Index

Inputs

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.

Outputs

No Outputs

Usage Examples

Variables File

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

Environment Variables

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.

Example Files that contain Octostache Substitution Syntax

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>

Workflow

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/[email protected]
        with:
          variables-file: ./substitution-variables.yml
          files-with-substitutions: ./src/DemoApp19/DemoApp19.csproj,./src/DemoApp19/Bff/FrontEnd/scripts/build-variables.js,./src/**/*.html
        env:
          # Note that this value would be used over the value from the example variables file
          LaunchDarklyKey: ${{ secrets.LAUNCH_DARKLY_API_KEY }}

Contributing

When creating PRs, please review the following guidelines:

  • The action code does not contain sensitive information.
  • At least one of the commit messages contains the appropriate +semver: keywords listed under Incrementing the Version for major and minor increments.
  • The action has been recompiled. See Recompiling Manually for details.
  • The README.md has been updated with the latest version of the action. See Updating the README.md for details.

Incrementing the Version

This repo uses git-version-lite in its workflows to examine commit messages to determine whether to perform a major, minor or patch increment on merge if source code changes have been made. The following table provides the fragment that should be included in a commit message to active different increment strategies.

Increment Type Commit Message Fragment
major +semver:breaking
major +semver:major
minor +semver:feature
minor +semver:minor
patch default increment type, no comment needed

Source Code Changes

The files and directories that are considered source code are listed in the files-with-code and dirs-with-code arguments in both the build-and-review-pr and increment-version-on-merge workflows.

If a PR contains source code changes, the README.md should be updated with the latest action version and the action should be recompiled. The build-and-review-pr workflow will ensure these steps are performed when they are required. The workflow will provide instructions for completing these steps if the PR Author does not initially complete them.

If a PR consists solely of non-source code changes like changes to the README.md or workflows under ./.github/workflows, version updates and recompiles do not need to be performed.

Recompiling Manually

This command utilizes esbuild to bundle the action and its dependencies into a single file located in the dist folder. If changes are made to the action's source code, the action must be recompiled by running the following command:

# Installs dependencies and bundles the code
npm run build

Updating the README.md

If changes are made to the action's source code, the usage examples section of this file should be updated with the next version of the action. Each instance of this action should be updated. This helps users know what the latest tag is without having to navigate to the Tags page of the repository. See Incrementing the Version for details on how to determine what the next version will be or consult the first workflow run for the PR which will also calculate the next version.

Code of Conduct

This project has adopted the im-open's Code of Conduct.

License

Copyright © 2024, Extend Health, LLC. Code released under the MIT license.

octostache-action's People

Contributors

bradyclifford avatar danielle-casella-adams avatar dependabot[bot] avatar hpractv avatar izep avatar josephdschwartz avatar mike-schenk avatar stevematney avatar

Watchers

 avatar  avatar  avatar

octostache-action's Issues

Large contents to download on every workflow job run

I have been noticing that this action (latest v4) is taking an average of 5-10 seconds to download (65 MB in size compressed) prior to the execution of the job. I looked at a few workflows in different repos and see the same behavior.

Is there anyone to reduce the size of that repo / tag?

Looks like you are compiling both windows and linux versions as part of the same tag. Perhaps at least those could be broken out into their own actions to reference? Like im-open/octostache-action/linux@v4. If not, maybe a separate tag? im-open/octostache-action@linux-v4

I am not 100% sure if Github will only download what is in the linux folder instead of the entire repo.

If I isolate just the linux compiled code, that is still 32 MB compressed. Would it be possible to expose a version that removes all of the core DotNet SDK (not self-contained 1MB) and have it rely on what is already instead on the runner?

im-open/octostache-action@linux-small-v4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.