Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated set-output command with environment file #1336

Open
jongwooo opened this issue Feb 8, 2023 · 13 comments · May be fixed by #1337
Open

Replace deprecated set-output command with environment file #1336

jongwooo opened this issue Feb 8, 2023 · 13 comments · May be fixed by #1337
Labels
enhancement New feature or request

Comments

@jongwooo
Copy link

jongwooo commented Feb 8, 2023

Describe the enhancement
In workflow, 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/

@paolorevillosa
Copy link

Does anyone find a fix for this?

@jongwooo
Copy link
Author

@jongwooo
Copy link
Author

jongwooo commented Feb 22, 2023

@paolorevillosa Oh I just saw your comment #1218 , what I mentioned above was for workflow and I didn't find a solution for core.setOutput in actions/core. If I find a solution, I'll share it with you.

@ghost
Copy link

ghost commented Apr 10, 2023

I'm experiencing this as well, it seems that the setOutput function in core does both the new way, and then the old way. Perhaps for backwards compatibility? Regardless, it would be good to get some clarification if there are plans to remove the old way from this library, and if we can just ignore the warning.

@twohlix
Copy link

twohlix commented May 11, 2023

@ksaunders the code I'm reading only does it one of the ways. But it keeps running it the old way for one of my actions. Code I'm seeing 1.10.0:

export function setOutput(name: string, value: any): void {
  const filePath = process.env['GITHUB_OUTPUT'] || ''
  if (filePath) {
    return issueFileCommand('OUTPUT', prepareKeyValueMessage(name, value))
  }

  process.stdout.write(os.EOL)
  issueCommand('set-output', {name}, toCommandValue(value))
}

so if process.env['GITHUB_OUTPUT'] is empty it does it the old way with issueCommand('set-output']), but if its not empty it does it the new way.

One of my actions must be evaluating process.env['GITHUB_OUTPUT'] to empty as I'm using actions/core 1.10.0 and still getting the set-output warning.

Seems frustrating that the library which we're supposed to use will sometimes try it in a deprecated way. I'm also pretty bad at debugging github actions so I'm drawing a blank why my action would evaluate the GITHUB_OUTPUT as not there?

@rentziass
Copy link
Member

Hey @twohlix 👋 you're correct in that old behaviour is still present in actions/core for backwards compatibility reasons. Runner should be setting GITHUB_OUTPUT in your jobs, would you able to please validate the env variable is there and is not being unset/overwritten? You should only get a warning if one of this is true:

  • actions/core < 1.10.0
  • GITHUB_OUTPUT is not set
  • something is issuing the command using STDOUT (i.e. echo "::set-output name={name}::{value}")

Does your action have any other dependencies that could affect this? Also if your action is public I'd be happy to have a look :)

@ghost
Copy link

ghost commented May 19, 2023

I see <1.10.0 mentioned, but there is no version since: https://www.npmjs.com/package/@actions/core?activeTab=versions.

While I agree that the code inside of @actions/core is correct on main, the code you're referring to was never released, as far as I can tell.

Incorrect (1.10.0): https://github.com/actions/toolkit/blob/%40actions/core%401.1.0/packages/core/src/core.ts (see below)
Correct, but unreleased: https://github.com/actions/toolkit/blob/main/packages/core/src/core.ts#L192

So I think we can clear this up if GitHub makes a new release of @actions/core, and I update the dependency here.

@ghost
Copy link

ghost commented May 19, 2023

Actually, I must be wrong, because manually inspecting the package shows that it's correct code. I linked the 1.1.0 tag, not the 1.10.0 tag. So I am mistaken. I'll keep looking. We use 1.10.0 here, which is why I am so confused.

@rentziass
Copy link
Member

@ksaunders are you 100% sure the warning is coming from your action and not something else within the job? If your action is public also happy to have a look!

@ghost
Copy link

ghost commented May 19, 2023

As it turns out, it was a build issue. For some reason the Vercel ncc bundler we were using would not recompile the setOutput function when we updated to 1.10.0 until I blew away the dist folder entirely, now I have manually verified the code.

Sorry for the wild goose chase folks. Thanks for the help. 1.10.0 LGTM.

@twohlix
Copy link

twohlix commented May 22, 2023

Does your action have any other dependencies that could affect this? Also if your action is public I'd be happy to have a look :)

I figured out my issue. Was indeed related to a dependency in the action preventing a real upgrade from being packaged. Apologies for the false alarm.

@atoomic
Copy link

atoomic commented Jan 2, 2024

@rentziass my action is using core.setOutput which then raise some warnings
what are the suggested alternate to write some output instead? console.log? other?

view https://github.com/perl-actions/install-with-cpm/blob/f1a3c07b144a476307db782753096b2c7690d968/index.js#L30

Reported to the action repo as perl-actions/install-with-cpm#15

async function install_cpm(install_to) {
  const version = core.getInput("version");
  const url = `https://raw.githubusercontent.com/skaji/cpm/${version}/cpm`;

  core.setOutput(`Get cpm from ${url}`);

  const cpmScript = await tc.downloadTool(url);

  core.setOutput("cpm", cpmScript);

here is an example usage where the deprecation warning is visible
https://github.com/cpanel/Test2-Harness-Renderer-JUnit/actions/runs/7390262832

thanks

@atoomic
Copy link

atoomic commented Jan 2, 2024

note: I just fixed it using core.info instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
@atoomic @twohlix @rentziass @paolorevillosa @jongwooo and others