Figure out a way to set global/job-wide env vars
Closed this issue · 1 comments
meeDamian commented
Currently the options are (they all suck):
- Inject variables to workflow files in a script run before each commit
- ex:
meeDamian/simple-qemu
/scripts/generate-workflows.sh#L28 - cons: complex; magic; gotta remember to run it each time.
- ex:
- Use
jobs.<job>.env
- ex:
meeDamian/github-actions-bugs
/.github/workflows/job-env-vars.yml#L20 - cons: static (can't set it to anything dynamic); needs to be hardcoded…
- discussion: https://github.community/t5/GitHub-Actions/Support-global-environment-variables/m-p/30488/highlight/true#M445
- ex:
- Use step output
- ex:
meeDamian/docker-bitcoind
/.github/workflows/on-tag.yml#L28-L37, and then used: #L57, #L65, or #L66 - cons: inefficient (lots to write); not clear; hacky; ugly
- ex:
- Repeat a lot
- ex:
meeDamian/docker-bitcoind
/.github/workflows/on-tag.yml#L123, #L132, #L138, #L146 - cons: Brainded repetition; Easy to make mistake; changing it requires changes everywhere; hard to see when one is different…
- ex:
- Use secrets 😅
- no examples…
- cons: all occurrences hidden…; nobody knows what's actually happening; doesn't work on forked repos(discussion)
meeDamian commented
Solution has been found here, and it's:
echo ::set-env name=action_state::yellow
Docs: https://help.github.com/en/articles/development-tools-for-github-actions#set-an-environment-variable-set-env
Example: https://github.com/meeDamian/github-actions-bugs/blob/3045c70062faedced72ed33357ed2f7f31a4372f/.github/workflows/set-env-var-in-step.yml
I'll close this issue when code is updated.