Warning for `set-output` command is deprecated and will be disabled soon. won't go away even with updating the code to new command syntax

huangapple go评论65阅读模式
英文:

Warning for `set-output` command is deprecated and will be disabled soon. won't go away even with updating the code to new command syntax

问题

I'm here to help with the Chinese translation. Please provide the specific parts you'd like translated.

英文:

I am trying to update the 'set-output' syntax in my GitHub workflow, but nothing that I have done has cleared the warning. I followed the guide GitHub gave, but am I missing something, or is the $() miss placed?

It currently uses actions/checkout@v3, which I think also impacts it.

jobs:

  build:

    runs-on: ubuntu-latest

    outputs:
      branch: ${{ steps.extract_branch.outputs.branch }}
      channel: ${{ steps.extract_channel.outputs.channel }}

    steps:
    - uses: actions/checkout@v3
      # In this step, this action saves a list of existing images,
      # the cache is created without them in the post run.
      # It also restores the cache if it exists.
    - name: Install Octopus CLI 🐙
      uses: OctopusDeploy/install-octopus-cli-action@v3
    - name: Extract branch name
      shell: bash
      id: extract_branch
      run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
      # run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
    - name: Determine Octopus Deployment Channel
      shell: bash
      id: extract_channel
      run: |
          BRANCH="${{ steps.extract_branch.outputs.branch }}"
          CHANNEL="Features"
            if [[ "$BRANCH" == "main" ]] || [[ "$BRANCH" == "release/*" ]]; then
              CHANNEL="default"
            fi
            
            echo "##[set-output name=channel;]$(echo $CHANNEL)"
        # echo "channel=$(echo $CHANNEL)" >> $GITHUB_OUTPUT

annotations ,
output code

答案1

得分: 1

如果你打开日志,警告应该会出现在引发警告的操作或脚本部分:

Warning for `set-output` command is deprecated and will be disabled soon. won't go away even with updating the code to new command syntax

更新后的脚本仍然保留了旧的语法,新的语法已经被注释掉:

echo "##[set-output name=channel;]$(echo $CHANNEL)"
# echo "channel=$(echo $CHANNEL)" >> $GITHUB_OUTPUT

更新为:

echo "channel=$(echo $CHANNEL)" >> $GITHUB_OUTPUT

将工作流更新为以下内容,警告将消失:

jobs:
  # 这个工作流包含一个名为“build”的单一作业
  build:
    # 作业将在其中运行的运行器类型
    runs-on: ubuntu-latest

    # 步骤代表将作为作业一部分执行的任务序列
    steps:
    - uses: actions/checkout@v3
      # 在此步骤中,此操作将保存现有图像列表,
      # 并在后运行时创建不包括它们的缓存。
      # 如果缓存存在,则还会恢复缓存。
    - name: Install Octopus CLI 🐙
      uses: OctopusDeploy/install-octopus-cli-action@v3
    - name: Extract branch name
      shell: bash
      id: extract_branch
      run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
    - name: Determine Octopus Deployment Channel
      shell: bash
      id: extract_channel
      run: |
          BRANCH="${{ steps.extract_branch.outputs.branch }}"
          CHANNEL="Features"
            if [[ "$BRANCH" == "main" ]] || [[ "$BRANCH" == "release/*" ]]; then
              CHANNEL="default"
            fi
            
            echo "channel=$(echo $CHANNEL)" >> $GITHUB_OUTPUT          

如果这不是完整的工作流程,那么一些其他任务必须记录这些警告。

尝试下载完整的日志存档以找到记录警告的确切位置:

Warning for `set-output` command is deprecated and will be disabled soon. won't go away even with updating the code to new command syntax

根据您提供的日志,EnricoMi/publish-unit-test-result-action版本远远落后了。你的工作流使用的是1.31版本,而2.6.1版本已经发布了。1.31版本仍然将日志记录到输出中

为了更容易保持更新,启用GitHub Actions的Dependabot版本更新。在你的仓库中添加.github/dependabot.yml

version: 2
updates:
  - package-ecosystem: "github-actions"
    directory: "/" # Package manifests 的位置
    schedule:
      interval: "weekly"

并在你的仓库设置中启用版本更新:

Warning for `set-output` command is deprecated and will be disabled soon. won't go away even with updating the code to new command syntax

这样GitHub会自动告诉你哪些操作落后了。

英文:

If you open the logs, the warning should be right in the section of the action or script causing the warning to be issued:

Warning for `set-output` command is deprecated and will be disabled soon. won't go away even with updating the code to new command syntax

The updated script still has the old syntax, with the new syntax commented out:

echo "##[set-output name=channel;]$(echo $CHANNEL)"
# echo "channel=$(echo $CHANNEL)" >> $GITHUB_OUTPUT

Update that to:

echo "channel=$(echo $CHANNEL)" >> $GITHUB_OUTPUT

Updated the workflow to the one below and the warnings are gone:

jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
    - uses: actions/checkout@v3
      # In this step, this action saves a list of existing images,
      # the cache is created without them in the post run.
      # It also restores the cache if it exists.
    - name: Install Octopus CLI 🐙
      uses: OctopusDeploy/install-octopus-cli-action@v3
    - name: Extract branch name
      shell: bash
      id: extract_branch
      run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
    - name: Determine Octopus Deployment Channel
      shell: bash
      id: extract_channel
      run: |
          BRANCH="${{ steps.extract_branch.outputs.branch }}"
          CHANNEL="Features"
            if [[ "$BRANCH" == "main" ]] || [[ "$BRANCH" == "release/*" ]]; then
              CHANNEL="default"
            fi
            
            echo "channel=$(echo $CHANNEL)" >> $GITHUB_OUTPUT

If this isn't the complete workflow, then some other task must be logging these warnings.

Try downloading the full log archive to find the exact location the warning is logged:

Warning for `set-output` command is deprecated and will be disabled soon. won't go away even with updating the code to new command syntax

Based on the logs you attached, the EnricoMi/publish-unit-test-result-action is way behind. Your workflow uses 1.31, while 2.6.1 is out already. 1.31 still logs to the output.

To make it easier to stay up to date, enable Dependabot-version-updates for GitHub Actions. Add .github/dependabot.yml to your repo:

version: 2
updates:
  - package-ecosystem: "github-actions"
    directory: "/" # Location of package manifests
    schedule:
      interval: "weekly"

And enable version updates in your repo settings:

Warning for `set-output` command is deprecated and will be disabled soon. won't go away even with updating the code to new command syntax

That way GitHub will automatically tell you what actions are falling behind.

huangapple
  • 本文由 发表于 2023年3月31日 03:08:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/75892082.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定