Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save BertiKarsunke/7cff2a605fa6c1ce72807f6dd5d40023 to your computer and use it in GitHub Desktop.
Save BertiKarsunke/7cff2a605fa6c1ce72807f6dd5d40023 to your computer and use it in GitHub Desktop.
Auto-setting FASTLANE_SESSION on CI
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