-
Notifications
You must be signed in to change notification settings - Fork 962
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
Support pre and post steps in Composite Actions #1478
Comments
I've also faced this need. Subscribing. |
@webknjaz you might want to use - name: Release
uses: ./utils/with-post-step
with:
main: |
echo '${{ inputs.gcr_token }}' | docker login gcr.io -u _json_key --password-stdin
echo '${{ inputs.gh_token }}' | docker login ghcr.io -u gha --password-stdin
echo '${{ inputs.docker_pass }}' | docker login docker.io -u '${{ inputs.docker_user }}' --password-stdin
dockerRelease ${{ inputs.architecture }} ${{ inputs.collection }} ${{ inputs.images }}
post: for registry in gcr.io ghcr.io docker.io; do docker logout "$registry"; done |
@umarcor I was considering something like this. Will it run at the end of the job execution or at the composite action exit? |
When I use it in a composite action, I call that action once only. Therefore, there is no difference between the end of the composite action or the end of the job. However, according to documentation, all post steps are executed at the end of the job, in reverse order. |
Supporting |
I have a use-case for this as well having a In this case I want to inject a task at the end of the workflow that keeps the runner alive a bit longer for debugging purposes. Adding a wait at the end works as a workaround for now:
|
Anyone know what he magic syntax would be to include such local action in the composite action repo?
in the action YAML will be relative to therepo root, not relative to the composite's |
Maybe |
Tried that. Not making actions happy:
For now fixed by passing in the full action path:
But I consider this a bug... I'd expect a composite action to be able to reference its own local actions. |
This would make it a lot easier to create quick and easy actions that cache things for various common tools/languages. Excited to hear it's already on the roadmap! |
When is this planned? Seems like a fundamental feature to me |
+1 |
Just writing in support - would have a lot of value in the context of "write secret --> $action --> remove secret" tasks |
Please add this functionality, thanks |
Hi @ethomson! Do you have any news for us? Had it been added to the roadmap (if yes, maybe you could share the ETA) or not yet? Thanks. |
@fabasoad, according to the bio (https://github.com/ethomson) he does not work for GitHub anymore. You might want to ping/ask @chrispat and/or @TingluoHuang. |
The The place that this has come up most frequently for me is wanting to have a composite action that executes |
I came here to solve the exact same problem as @philomory ... ergonomically and conditionally running cache/restore and cache/save. |
This would solve a lot of headaches around cache logic and such. Especially since it's not possible to use post steps in Reusable Workflows either. |
Hello, any updates about this ? |
We, the Ruby project, are using the gacts/run-and-post-run GitHub Action as alternative at the commit. |
Another workaround, add this to the top of your run if it is sh/bash:
edit: Can anyone explain the thumbs down? Am I mistaken that this works to achieve a post cleanup that always runs? |
so this is almost equivalent (except for docker run "${{ steps.build-image.outputs.image }}"
docker image rm "${{ steps.build-image.outputs.image }}" || true |
The post step is intented to run once the whole github job is done, not just after the current step/action |
Hi @ethomson, any ETA on when this would be available? It's still relevant |
Describe the enhancement
Currently, three Action types are supported: Docker, JavaScript and Composite (see https://docs.github.com/en/actions/creating-actions/about-custom-actions#types-of-actions). However, features
pre
,pref-if
,post
andpost-if
are only is supported in JavaScript Actions only (see https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-javascript-actions). Therefore, users writing workflows/actions using some scripting language such as Python are forced to wrap the steps in JavaScript in order to register pre and post steps. See, for example, https://github.com/pyTooling/Actions/tree/main/with-post-step:The complexity might be simplified if Python or Bash or PowerShell were supported similarly to JavaScript:
Additional information
Alternatively, since regular steps support Python as a built-in shell already, the same capability might be achieved if Composite Actions supported fields
pre
andpost
as a complement tosteps
. For instance:/cc @thboop, per #646 (comment)
The text was updated successfully, but these errors were encountered: