How to export data from Fastlane to next step in GitHub Actions

Hello,

I have a GitHub Actions job that contains 2 steps:

  1. Fastlane
  2. Print message

In Fastlane I’m getting some data and trying to expose it as ENV variable to be available for the next GA step

Fastlane part that I’ve tried:

echo(message:"VERSION_NAME=#{name} >> $GITHUB_ENV")
ENV["VERSION_NAME"] = name
echo(message:"::set-env name=VERSION_NAME::#{name}")

GH Part that I use

- name: Build with Fastlane
  run: fastlane code
- name: Print the message
   run: echo "Build for ${{ env.VERSION_NAME }} is ready for testing."

Any ideas how to share data I got inside Fastlane between steps?

I’m not familiar with Fastlane, but this looks like you’re printing most (minus the echo) of the shell command that would work.

You need to write the variable in the form NAME=VALUE to the file named by the GITHUB_ENV environment variable, however file access works in Fastlane.

Thank you for pointing that out. I’ve replaced the echo with sh that executes the command as script, but the result is mostly the same

The echo part of the shell command seems to be missing.

Thank you very much for the help, indeed this result will work:

sh("echo VERSION_NAME=#{name} >> $GITHUB_ENV")
sh("echo VERSION_CODE=#{code} >> $GITHUB_ENV")
- name: Print the message
   run: echo "Build for ${{ env.VERSION_NAME }}(${{ env.VERSION_CODE }}) is ready for testing."

1 Like