Search code examples
githubgithub-actionsdeprecation-warning

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


Solution

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

    The warning is highlighted in the actual logs

    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:

    enter image description here

    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:

    enter image description here

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