Github 操作 `set-output` 命令已弃用

标签 github yaml github-actions workflow building-github-actions

我有以下 github 操作,我收到以下警告:

build-android
The `set-output` command is deprecated and will be disabled soon. 
Please upgrade to using Environment Files. For more information see: 
https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

但我没有使用set-output

on: workflow_dispatch

name: Build
jobs:
  build-android:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v3

      - name: Install npm dependencies
        run: npm install

      - name: Build Android Release
        run: cd android && ./gradlew assembleRelease

      - name: Read package.json
        uses: tyankatsu0105/read-package-version-actions@v1
        id: package-version

      - name: Upload Artifact
        uses: actions/upload-artifact@v3
        with:
          name: app-release.apk
          path: android/app/build/outputs/apk/release/

      - name: Create Github Release
        uses: ncipollo/release-action@v1
        with:
          artifacts: "android/app/build/outputs/apk/release/app-release.apk"
          tag: "v${{ steps.package-version.outputs.version }}"
          replacesArtifacts: false
          token: ${{ secrets.GITHUB_TOKEN }}
          allowUpdates: true

最佳答案

由于您的工作流程未使用set-output,因此您需要查看外部操作依赖项。它们之一或两者都使用过时的语法。

对于基于 JS 的操作,@actions/core 添加了对 1.10.0 中输出环境文件的支持

  1. tyankatsu0105/read-package-version-actions@v1

此操作的 v1 于 2019 年发布,因此毫无疑问这是您问题的根源之一。它确实使用 set-output ,但是来自旧版本的@actions/core

您还可能收到有关 node 12 的警告弃用。

  • ncipollo/release-action@v1
  • 此操作的最新更新于 2022 年 12 月,在节点 16 上运行,使用 set-output ,但有 correct version @actions/core

    基于此,#1 是您的问题操作。现在,您有几个选择,添加请求更新的问题,提交包含必要更改的 PR,或者找到支持您需求的最新操作。

    关于Github 操作 `set-output` 命令已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75972484/

    相关文章:

    GitHub Actions 无效工作流程文件错误

    github - 有没有办法通过 GitHub 操作推送更改?

    git - 如何在 GitHub 中恢复已删除的 fork ?

    git - macOS Sierra 更新后无法同步 git

    yaml - 如何在多行的 `script` 步骤中中断单个命令

    ruby-on-rails - 在 YAML 字符串中嵌入 YAML 别名

    json - 如何将 Github secret 传递到 JSON 文件

    github - Rstudio:更改项目的 git 版本控制的来源

    javascript - github 项目页面资源解释为脚本,但使用 MIME 类型 text/htm 传输

    ruby-on-rails - 避免本地化文件重复