Skip to content

Instantly share code, notes, and snippets.

@joshbuchea
Forked from joshdholtz/.env
Created May 14, 2022 01:22
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 joshbuchea/8797836527d541a7ecc7e083b6b8a929 to your computer and use it in GitHub Desktop.
Save joshbuchea/8797836527d541a7ecc7e083b6b8a929 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