Jekyll to detect the build waits the JEKYLL_ENV variable: https://jekyllrb.com/docs/configuration/environments/
Netlify sets the CONTEXT variable: https://www.netlify.com/docs/continuous-deployment/?_ga=2.28134843.62454114.1555938051-984068889.1555938051#environment-variables
As result Jekyll doesn't see that build i
Netlify's CONTEXT variable is not intended to be the same as Jekyll's JEKYLL_ENV. So, you'll want to set JEKYLL_ENV separately, probably using netlify.toml? Something like this may work:
# this will be the default for every branch other than the production branch
[build.environment]
JEKYLL_ENV="development"
# only for production branch, override to production
[context.production.environment]
JEKYLL_ENV="production"
I had the same issue and sorted it by adding JEKYLL_ENV in the environment variables in Netlify settings page. No need to add a toml file.
I successfully tested three different ways to set the JEKYLL_ENV environment variable, which can then be accessed in Liquid templates as jekyll.environment:
netlify.toml: Set the env var in the build command directly
# global context
[build]
publish = "_site/"
command = "JEKYLL_ENV=\"netlify\" jekyll build"
netlify.toml: Set a build environment
# global context
[build]
publish = "_site/"
command = "jekyll build"
environment = { JEKYLL_ENV = "netlify" }
netlify.toml: Run a custom build script
# global context
[build]
publish = "_site/"
command = "sh netlify.sh"
netlify.sh: Set the env var in the build command
JEKYLL_ENV="netlify" jekyll build
Related
When I'm trying to run an action via Github with my self hosted runner it is not possible to load the environment variables from my .zshrc file (e.g. the PATH)
When I'm executing "printenv" I will get e.g for PATH:
PATH=/usr/bin:/bin:/usr/sbin:/sbin
but it should be:
PATH=/Users/jenkins/.rbenv/shims:/opt/homebrew/opt/openjdk/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/jenkins/.rbenv/shims:/opt/homebrew/opt/openjdk/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/bin:/bin:/usr/sbin:/sbin
It is only possible when I call source ~/.zshrc before the printenv.
Is it possible to open the shell directly with the zshrc env variables without sourcing it manually?
As far as I understood, the "secret" ACTIONS_STEP_DEBUG is set to true when you relaunch a workflow in "debug mode" on Github Actions for a repository.
Now I'd like to hook onto this like a switch to print additional information from python commands that are executed in my actions/steps.
Is it possible to turn ACTIONS_STEP_DEBUG into an environment variable or how could I access it from within a step (like bash or even in python)?
So found I can use the secrets, to set an env, however only for workflows, not for the action, for some reason.
env:
IS_STEP_DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG }}
I have a bash script that sets a series of environment variables.
My action includes the following two steps:
- name: Set env variables
run: source ./setvars.sh
- name: dump env variables
run: env
I notice setvars.sh runs successfully, but all of the variables defined inside it are missing after the steps.
How can I use a bash .sh script to add environment variables to the context of the workflow?
I don't see environment variables defined by sourcing file in GitHub Actions workflow.
I only see them defined as map (key-value) at the job or workflow level (since oct. 2019).
See if you can cat your file and append its content to GITHUB_ENV.
I try to build my jekyll project on production mode using JEKYLL_ENV variable but it doesn't work.
Jekyll documentation specifies to set a production environment in the build command :
JEKYLL_ENV=production jekyll build
But on Windows, this type of syntax is not correct.
I used this following syntax, but it looks not working:
jekyll build JEKYLL_ENV=production
I also set 'manually' this environment variable but doesn't take effect :
setx JEKYLL_ENV production & jekyll build
and
set JEKYLL_ENV=production & jekyll build
I ran into this as well with my Windows/Jekyll setup. My workaround is to have production and development config files and set the environment variable in each file.
// _config.yml
environment: production
...<other config settings>...
--------
// _config_dev.yml
environment: development
Your prod environment should run jekyll build which automatically uses _config.yml. Your dev environment should run jekyll <command> --config _config.yml,_config_dev.yml. In the Jekyll config docs, "Settings in later [config] files override settings in earlier files." So, you can set the variable in prod and dev config files and use --config _config.yml,_config_dev.yml to set the variable in dev.
To do stuff with it in Jekyll, use Liquid statements to check for the environment variable. Config files set site variables, so check site.environment
// some file that will be processed by Jekyll
{% if site.environment == "production" %}
<do prod stuff>
{% elsif site.environment == "development" %}
<do dev stuff>
{% endif %}
On windows you should run two commands:
the first command set env to production
set JEKYLL_ENV=production
the second command run jekyll build or jekyll server
jekyll build
when you use development evn, run this command again:
set JEKYLL_ENV=development
This worked for me:
set JEKYLL_ENV=production | jekyll build
Running the two commands separately like Thxopen suggested worked. Then I tried running the two commands on one line using the separator character as mentioned here, and it worked nicely.
I need to do the following
Change environment variables according to the published env. Set Set up cron jobs according to the dev. I I would like to run just 1 command line "eb deploy dev" or something similar.
Use setenv
You can set environment variables with setenv. These will then be remembered for that environment.
More details: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-setenv.html
Example
For example, suppose you have created an EB environment called 'staging' and you want to set the variable DB to 'localhost', you can use:
eb setenv DB=localhost -e staging
Crons
Now that you have a different environment variables, you can check them in a script etc. to decide if the cron should be set up.
Note that the crons may not actually have access to your environment variables so you need to set those again for the cron while setting up the cron.
This is my solution to the problem, it took some time to setup but now i can do all the changes with 1 command line.
Make your own folder with all the files for all the environments.
In .ebextensions folder setup empty config files for eb.
npm runs a script named "deploy.js" together with the flag of the specific env.
The script will do the following
copy the requested env data to the empty files according to the env
git stash the changes of .ebextensions folder (eb deploys using git)
eb use env
eb deploy
So now i can tun npm run deploy:dev and everything runs