Forked from gaelfoppolo/retrieve_fastlane_session.rb
Created
January 3, 2022 05:35
-
-
Save BertiKarsunke/7cff2a605fa6c1ce72807f6dd5d40023 to your computer and use it in GitHub Desktop.
Auto-setting FASTLANE_SESSION on CI
This file contains hidden or 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
lane :retrieve_fastlane_session do | |
# runs shell | |
# this needs SPACESHIP_SKIP_2FA_UPGRADE=1 flag | |
spaceauth_output = `bundle exec fastlane spaceauth` | |
# regex the output for the value we need | |
fastlane_session_regex = %r{Pass the following via the FASTLANE_SESSION environment variable:\n(?<session>.+)\n\n\nExample:\n.+} | |
new_session = nil | |
if match = spaceauth_output.match(fastlane_session_regex) | |
# strip out the fancy formatting | |
new_session = match[:session].gsub("\e[4m\e[36m", "").gsub("\e[0m\e[0m", "") | |
end | |
# yell and quit if unable to parse out session from spaceauth output | |
if new_session.nil? | |
puts "Unable to obtain new FASTLANE_SESSION via fastlane spaceauth" | |
exit 1 | |
else | |
ENV['FASTLANE_SESSION'] = new_session | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment