fastlane actions are the ❤️ of fastlane. Frequently, we use the available actions in our Fastfile passing the required parameters to run it. Run an action from the terminal could be very helpful when we have errors running the action or just because we want to test it.
Available actions
To list in fastlane all the available actions, we need to run in our terminal:
So the output should reflect all the available actions up to date:
Action documentation
Now we have all the available actions if we want to see the documentation about one of these we run in our terminal:
For example, let’s get the docs for the action unlock_keychain running in our terminal:
So we should get all the documentation about the specified action:
We can see the key, description, environment variable name and default value of each parameter, and a link to fastlane docs for more information about the action.
Run the action from the terminal
Now we have all the actions available and its docs we can see how to run the actions directly from your terminal. To run an action from the terminal we can run the following command in our terminal:
fastlane should start asking for the parameters required to run the action. Let’s see in action run it the action unlock_keychain:
After executing the action with the required parameters successfully we should see the result of the action:
That is great! However, what if we want to pass parameters when we run the action directly? Well, fastlane have options for it too 👍.
Passing parameters to actions from your console
To pass parameters from the terminal to the action we can specify parameter:value for each one of the parameters. Let’s see in action running the following command from the terminal:
The action should work without requiring the required parameters. Nevertheless, according to the fastlane docs, there are some cases when might not be able to set some parameters using this method.
Another workaround and a solution to the parameters were not able to set directly while running the action is to set the environment variables returned in the docs about the action before running the lane. We can do this using the export command in the terminal running the following:
In that way when we run the action, the values would be available. The environment variables set only will be available while the terminal session exists, try to use always the solution passing the parameters.
Conclusion
We covered how to run fastlane actions from the terminal and how to pass parameters to the actions.