在github操作中使用多行运行命令的输出

发布于 2025-02-11 22:58:37 字数 855 浏览 0 评论 0原文

我想运行多个运行命令,但也使用每行的输出作为下一行的输入。

这样的东西。

- 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))

当我直接从MACOS终端(按线路)直接运行命令时,上述功能可行。但是,当我运行github操作时,它似乎并不能保存输出或在实际的推荐线中保存输出。

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).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文