pathogen-repo-ci: Allow caller to pass env vars#23
Merged
Conversation
tsibley
added a commit
to nextstrain/mpox
that referenced
this pull request
May 23, 2022
Drop if merged after nextstrain/.github#23 is merged.
This can be useful to set variables respected by Augur, Nextstrain CLI,
etc. Implemented ourselves as a workflow input since the usual job.env
block is not (yet?) supported by GitHub Actions for jobs which call a
reusable workflow.
The input value is a YAML-formatted string, which you can easily produce
by pretending you're writing normal nested YAML within a literal
multi-line block scalar (introduced by "|"):
with:
env: |
FOO: bar
I_CANT_BELIEVE: "it's not YAML"
When (if?) the usual job.env block is supported for reusable workflows,
it will be a small transformation for each caller to use it.
e74b3ed to
e9d4ffc
Compare
2 tasks
victorlin
approved these changes
May 23, 2022
Member
victorlin
left a comment
There was a problem hiding this comment.
Seems hacky but probably the best option for now!
| | yq --output-format json . | ||
| | jq --raw-output ' | ||
| to_entries | ||
| | map("\(.key)<<__EOF__\n\(.value)\n__EOF__") |
Member
There was a problem hiding this comment.
[non-blocking]
Is this heredoc for variables? How'd you know it works for $GITHUB_ENV? I tried running it directly:
I_CANT_BELIEVE<<__EOF__
it's not YAML
__EOF__
# bash: I_CANT_BELIEVE: command not found
Contributor
Author
There was a problem hiding this comment.
It's not standard Bash, but something that GitHub Actions implements, see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings.
Motivated by review comments.
Contributor
Author
Definitely hacky! but yeah… |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This can be useful to set variables respected by Augur, Nextstrain CLI,
etc. Implemented ourselves as a workflow input since the usual job.env
block is not (yet?) supported by GitHub Actions for jobs which call a
reusable workflow.
The input value is a YAML-formatted string, which you can easily produce
by pretending you're writing normal nested YAML within a literal
multi-line block scalar (introduced by "|"):
When (if?) the usual job.env block is supported for reusable workflows,
it will be a small transformation for each caller to use it.
Testing
Tested in a separate GitHub Actions testbed, though I may have mucked up the syntax in this particular file. We'll see when I try to use it!
Update: Usage in nextstrain/mpox#8 found a small place I mucked up, which is now fixed and that PR's CI ran successfully.