-
Notifications
You must be signed in to change notification settings - Fork 977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load env
from files
#655
Comments
A workaround would be to use jobs:
env:
runs-on: ubuntu-latest
outputs:
env: ${{ steps.import-env.outputs.result }}
steps:
- uses: actions/checkout@v2
- name: Import environment variables from a file
id: import-env
uses: actions/github-script@v2
with:
script: |
const env = parseEnv(`${process.env.GITHUB_WORKSPACE}/dev.env`);
Object.entries(env).forEach(x => core.exportVariable(...x)); // current job-level env
return env;
- name: Print environment variable
run: echo $ABC
env: ${{ fromJson(steps.import-env.outputs.result) }} # step-level env
build:
runs-on: ubuntu-latest
needs: [env]
env: ${{ fromJson(needs.env.outputs.env) }} # job-level env
steps:
- name: Print environment variable
run: echo $ABC Note I've used |
We wrote an action that loads yaml, json, or env files into the current jobs |
parseEnv is not defined:
|
Ended up doing it with the shell: - name: Import environment variables from a file
id: import-env
shell: bash
run: |
while read line; do
echo "$line" >> $GITHUB_ENV
done < ${{ env.ENV_FILE }} |
Why not just use run: cat ${{ env.ENV_FILE }} >> $GITHUB_ENV or run: < ${{ env.ENV_FILE }} >> $GITHUB_ENV |
Im completely new to powershell scripts. Can you post a windows runner script? Please |
I faced with the same question and made a export-env-action that you can use as one of your steps: constants.env file: PROTOCOL=https
HOST=example.com
PORT=8080
URI=${PROTOCOL}://${HOST}:${PORT} a step in your workflow: - uses: cardinalby/export-env-action@v1
with:
envFile: 'constants.env'
expand: 'true'
# env.PROTOCOL == 'https'
# env.HOST == 'example.com'
# env.PORT == '8080'
# env.URI == 'https://example.com:8080' |
Is there anyway to load from an services:
mysql:
image: mysql:5.7
ports:
- $DB_PORT:3306 |
First, I would warn you that if you store your creds in You case can make sense if you download env file from outside for example. Then, yes, you can use mentioned |
Jumping in here with another solution since some of these didn't exactly do what I needed, which was to load a regular env file like this: Into the env vars of the job itself so I can do other env replacement in subsequent steps without having to enumerate all the vars in the env file. This did the trick:
|
I have my ENV_FILE stored as a secret because it is quite large and has a few credentials in there. How could I load in from a secret instead of a file? Any references for the code above would be handy too. |
I use a secret in the repo for my env file (we keep an env file for LOCAL, DEV, CI and PRODUCTION) so was able to use this approach by adding the following to the start of my job - name: Create .env file from Secret
id: import-env
run: |
echo "${{ secrets.ENV_FILE }}" >> .env
- uses: cardinalby/export-env-action@v2
with:
mask: true
envFile: '.env' I'm not sure what best practice is here and my only concern is that For posterity, the following is what I was trying which lead me here because the variables were all printed to the console: - name: Setup environment
run: |
echo "${{ secrets.ENV_FILE }}" >> $GITHUB_ENV |
@moleary-gsa
You can achieve it by using
And pass the secrets to the steps where they are needed by accessing them as |
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify --all-features minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify --all-features minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify --all-features minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify --all-features minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify --all-features minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify --all-features minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify `--all-features` minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify `--all-features` minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify `--all-features` minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify `--all-features` minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
Thank you for your interest in the runner application and taking the time to provide your valuable feedback. We kindly ask you to redirect this feedback to the GitHub Community Support Forum which our team actively monitors and would be a better place to start a discussion for new feature requests in GitHub Actions. For more information on this policy please read our contribution guidelines. 😃 |
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify `--all-features` minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
It would be awesome if
env
could be loaded from a file. Example:The text was updated successfully, but these errors were encountered: