Skip to content

Instantly share code, notes, and snippets.

@ryanhanwu
Forked from joshdholtz/.env
Created February 23, 2021 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanhanwu/b7d751a727bbe365af37c24155d0820d to your computer and use it in GitHub Desktop.
Save ryanhanwu/b7d751a727bbe365af37c24155d0820d to your computer and use it in GitHub Desktop.
Using Dotenv and environment variables with fastlane
STUFF = this is some stuff
CONFIG = this is config 1
CONFIG = this is config 2
SOME_API_TOKEN = 123456789
fastlane_require 'dotenv'
before_all do
Dotenv.overload '.env.secret'
end
lane :test do
# Loaded from .env (by fastlane)
puts "STUFF: #{ENV['STUFF']}"
# Loaded from .env.secret (by us in before_all)
puts "SOME_API_TOKEN: #{ENV['SOME_API_TOKEN']}"
# Loaded from .env.(<env>) where <env> is passed in from `fastlane test --env <env>` (by fastlane)
# Ex: `fastlane test --env config` loads .env.config1
puts "CONFIG: #{ENV['CONFIG']}"
end
fastlane_require 'dotenv'
before_all do
Dotenv.overload '.env.secret'
end
$: fastlane test
STUFF: this is some stuff
SOME_API_TOKEN: 123456789
CONFIG:
$: fastlane test --env config1
STUFF: this is some stuff
SOME_API_TOKEN: 123456789
CONFIG: this is config 1
$: fastlane test --env config2
STUFF: this is some stuff
SOME_API_TOKEN: 123456789
CONFIG: this is config 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment