-
-
Save joshdholtz/cd077ccdddb608af00eb2466259e7ac0 to your computer and use it in GitHub Desktop.
Using Dotenv and environment variables with fastlane
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
STUFF = this is some stuff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONFIG = this is config 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONFIG = this is config 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SOME_API_TOKEN = 123456789 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.env.secret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fastlane_require 'dotenv' | |
before_all do | |
Dotenv.overload '.env.secret' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$: 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 |
@mgrachev FYI you have extra characters in the URL that prevent it from opening directly
@mgrachev FYI you have extra characters in the URL that prevent it from opening directly
Thanks! Fixed.
Is it possible to load env files outside of fastlane directory?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In addition to using environment variables, I can recommend the tool dotenv-linter - it’s a lightning-fast linter for .env files. Written in Rust. Maybe it would be useful for you.