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

Add save-state and set-output file commands #1178

Merged
merged 3 commits into from Sep 29, 2022
Merged

Conversation

rentziass
Copy link
Member

This adds support for the file command version of save-state and set-output that are being added to the runner in #2118.

In the case that these commands are being used on a runner that doesn't support the file-command versions they will fallback to the pre-existing workflow commands.

@rentziass rentziass requested a review from a team as a code owner September 13, 2022 16:58
packages/core/src/core.ts Outdated Show resolved Hide resolved
@@ -22,3 +23,25 @@ export function issueCommand(command: string, message: any): void {
encoding: 'utf8'
})
}

export function prepareKeyValueMessage(key: string, value: any): string {
const delimiter = `ghadelimiter_${uuidv4()}`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 on the refactor

Copy link
Collaborator

@thboop thboop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

rimrul added a commit to rimrul/rss-issues-action that referenced this pull request Oct 29, 2022
This allows us to automatically use the file based version [1]
of `set-output` instead of the deprecated stdout version that
will be removed on 31st May 2023. [2]

[1] actions/toolkit#1178
[2] https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

Signed-off-by: Matthias Aßhauer <mha1993@live.de>
@bradyclifford
Copy link

When will this find its way into actions/github-script@v6?

redian added a commit to redian/tar-action that referenced this pull request Jan 5, 2023
In version 1.10.0 of `@actions/core` they have fixed the warning we are getting for set-output in our github actions.

As per per this PR actions/toolkit#1178
And as discussed here actions/toolkit#1218
Comment on lines +34 to +38
if (key.includes(delimiter)) {
throw new Error(
`Unexpected input: name should not contain the delimiter "${delimiter}"`
)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check for the delimiter in the key feels a little misleading to me - if the key is user-controlled, it can still be used to add additional outputs if that's the risk being mitigated here; the delimiter doesn't capture the key, it just captures the value.

Suggested change
if (key.includes(delimiter)) {
throw new Error(
`Unexpected input: name should not contain the delimiter "${delimiter}"`
)
}

elliottkember added a commit to elliottkember/github-actions-query-branch-name that referenced this pull request Jul 20, 2023
The `@actions/core` package has been updated to squash this warning:

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

Notes:

> Action authors who are using the toolkit should update the @actions/core package to v1.10.0 or greater to get the updated saveState and setOutput functions.

https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md
> ### 1.10.0
> - `saveState` and `setOutput` now use environment files if available [#1178](actions/toolkit#1178)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants