Skip to content

Environment variables

Alessandro Fazzi edited this page Nov 27, 2019 · 1 revision

Environment Variables

Wordmove allows the use of environment variables in your movefiles. This is useful in order to protect sensitive variables and credentials, as well as make it easy to share movefiles between your team.

Environment variables are written using the ERB tags syntax:

"<%= ENV['YOUR_SECRET_NAME'] %>"

Variables set up

Environment variables can be set up using two methods:

Using the shell:

# bash
export PROD_DB_USER="username" PROD_DB_PASS="password"

# fish
set --export --global PROD_DB_USER "username"; set --export --global PROD_DB_PASS "password"

Using a .env file:

Wordmove supports the dotenv module.

Simply create a .env file next to your movefile structured as follows:

PROD_DB_USER="username"
PROD_DB_PASS="password"

Wordmove will take care of loading the file and making the environment variables ready to be used in your configuration file.

You may also use .env.{environmentname}, but this is discouraged.

Use them in your movefile.yml

Using the ERB syntax described above, write your movefile as follows:

production:
  database:
    user: "<%= ENV['PROD_DB_USER'] %>"
    password: "<%= ENV['PROD_DB_PASS'] %>"

System variables

You can use system variables to configure your movefile.

For example:

local:
  vhost: "http://wordpress-site.localhost"
  wordpress_path: "<%= ENV['HOME'] %>/[wordpress directory path]/"
  # wordpress_path will be substituted with /home/user_name/[wordpress directory path]