-
Notifications
You must be signed in to change notification settings - Fork 15
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 GHA ::set-output syntax #980
Replace deprecated GHA ::set-output syntax #980
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, a few questions/possible adjustments.
In the meantime, I'm going to manually PR this into our test pipeline on paketo-buildpacks/pipeline-builder-canary.
actions/action.go
Outdated
if !ok { | ||
panic(errors.New("GITHUB_OUTPUT is not set, see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter")) | ||
} | ||
writer, err := os.OpenFile(outputFileName, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0666) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason to not use os.Create(..)
? Typically, that is preferred for writing files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os.Create
passes the O_TRUNC
flag, we pass O_APPEND
instead.
Basically the same as >> "$GITHUB_OUTPUT"
vs > "$GITHUB_OUTPUT"
in bash would be. In their examples GitHub uses append.
I assume, if we truncate the file we would delete outputs that were created elsewhere. This might lead to subtle bugs, as GitHub Actions don't fail on missing values in their interpolation syntax.
So IMHO this is the better option, even if it is less readable.
My suggestions:
- Either I add a comment explaining the difference to
os.Open
- or I move the
os.OpenFile
call to a new helper function calledAppend
, with a doc comment that it works likeos.Open
, but uses the append instead of the truncate flag.
What would you prefer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ha. Ok. That makes perfect sense, don't want to truncate the file and wipe out previously written output.
To clarify the code I don't have a strong preference, but given a choice, I'd say let's go with the Append
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I called the method createOrAppend
:
- I guess it's better private, therefore lowercase
append
would collide with the built-in array append function.
A couple of other things...
Thanks |
Run `octo` using the commit from paketo-buildpacks/pipeline-builder#980. This is a test to make sure the changes are OK. Signed-off-by: Daniel Mikusa <dan@mikusa.com>
Co-authored-by: Daniel Mikusa <dan@mikusa.com>
d91eefc
to
536a7f4
Compare
536a7f4
to
d603692
Compare
Done |
Summary
Fixes #867
Use the new way of producing outputs in a github action as the old way is deprecated and will be removed (31st May 2023).
See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Use Cases
Pipelines will continue to work after May 31st 2023.
Checklist