Use outputs of multiline run commands in GITHUB actions

671 views Asked by At

I want to run multiple run commands, but also use the output of each line, as an input to next line.

Something like this.

- name: Upload to firebase and increment git tag
    if: github.ref == 'refs/heads/master'
    run: |
      //I want to save these outputs
      VERSION_NAME=$(./gradlew -q getVersionName -Pflavour="myapp" | tail -n 1)
      LATEST_TAG=$(git tag --list --sort=-version:refname "myapp/v*-snapshot.*" | head -n 1)
      CHANGE_LOG=$(bundle exec fastlane changelog tag:$LATEST_TAG)

      // Use the above outputs here
      ./gradlew -PversionCode=$((1000 + $GITHUB_RUN_NUMBER)) -PchangeLog=$CHANGE_LOG assembleRelease appDistributionUploadRelease
      bundle exec fastlane increment_git_tag app_name:'myapp' tag_type:'snapshot' version_name:$VERSION_NAME build_number:$((1000 + $GITHUB_RUN_NUMBER))

The above works when I run the commands directly from a macOS terminal(line-by-line). But when I run the GITHUB action, it does not seems to save the output or makeuse of it in the actual referring line(s).

0

There are 0 answers