Skip to content

Commit

Permalink
Add bin/interpolate-text-template
Browse files Browse the repository at this point in the history
Modifies the "Generate summary" step from the conda-base repo CI
workflow¹ into a separate script that can be used to interpolate any
text template with environment variables.

I will be using this in the reusable run-build workflow to create the
GitHub Action summary for AWS Batch builds. I also see this being useful
for creating Slack messages for automated builds such as the onstart
and onerror notifications that we use in ncov² if we decide to move the
notifications out of the pathogen workflows and into the GitHub Action
workflows.

¹ https://github.com/nextstrain/conda-base/blob/5655133be6864ede0acbf40b6b06222f9f2dc031/.github/workflows/ci.yaml#L107-L112
² https://github.com/nextstrain/ncov/blob/fcac1d16410b1b119a9af70afe7b9325a6e25083/workflow/snakemake_rules/export_for_nextstrain.smk#L499-L519
  • Loading branch information
joverlee521 committed May 25, 2023
1 parent 491acd4 commit 0f36d41
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ See also GitHub's [documentation on starter workflows](https://docs.github.com/e

Executable scripts that are used in our workflows.

- [interpolate-text-template](bin/interpolate-text-template)
- [write-envdir](bin/write-envdir)
- [json-to-envvars](bin/json-to-envvars)
- [yaml-to-envvars](bin/yaml-to-envvars)
12 changes: 12 additions & 0 deletions bin/interpolate-text-template
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
# usage: interpolate-text-template <text-template>
#
# Replaces ${x} in <text-template> with value of environment variable "x" and
# outputs the updated text to stdout.
#
# Modified from the conda-base repo's CI workflow:
# https://github.com/nextstrain/conda-base/blob/a2da0f5ef7e95f9db31678c2df00bd312c7b754a/.github/workflows/ci.yaml#L109-L111
#
set -eou pipefail

perl -pe 's/\$\{(.+?)\}/$ENV{$1}/ge' < "$1" \

0 comments on commit 0f36d41

Please sign in to comment.