Comments (15)
So it sounds like we would need to find an API that can map the workflow name to either ID or File Name.
The linked action above seems to use the current run id to figure out the workflow id so maybe we could change the workflow_id
parameter to be optional and when it is not provided, use the run id to cancel previous workflow runs.
from cancel-workflow-action.
I see. So the way I authored this action is that it runs in a separate workflow and then cancels all the workflows that you specify.
It sounds like you want this action to be the first step in each of your workflows so that it cancels previous runs without the need to configure the workflow id.
Is that correct?
from cancel-workflow-action.
First off, thanks a ton for offering this code :) My initial comment was a bit curt...!
I don't believe my request was the same as the original request in #2, but I do see that someone inflated the scope of the request in #2 (comment).
My feature request is for the case where someone has a workflow that takes ~10 minutes. If I push a small typo fix directly after my last push, I probably don't want to run both in parallel. So I would probably wish to run your action at the beginning of that workflow, and (if workflow_id
is unset) for it to just cancel the running workflow as it starts the new one. Right now, this takes a bit of searching through the GitHub UI to find workflow_id
and configure it.
So if I'm understanding correctly, whether you consider this a dup depends if you want to keep feature requests small and separate, or have both in that issue :)
from cancel-workflow-action.
It does not work, I've used 0.3.2 of this action, my workflow_id was set to Alpha Deploy and I got this error when running this action:
I think you're assuming :workflow_file_name
in the GitHub API docs means the name
key of your workflow file (e.g., Alpha deploy
), but I'm pretty sure it's actually the filename itself that this refers to (e.g., .github/workflows/alpha-deploy.yml
). You'll likely need to add some logic if you wish to support what you're looking for -- on top of fixing the number typing, that is
from cancel-workflow-action.
+1 maybe we could change the workflow_id parameter to be optional
from cancel-workflow-action.
Thanks, take a look at https://github.com/styfle/cancel-workflow-action/releases/tag/0.4.0
from cancel-workflow-action.
Are you suggesting the same as #2 or is this a different feature request?
from cancel-workflow-action.
It sounds like you want this action to be the first step in each of your workflows so that it cancels previous runs without the need to configure the workflow id.
I need exactly this behavior as well. I have 4 workflows setup that run by different triggers which should not be important. But whenever the same workflow is run and the branch name is equal, previous builds should be cancelled. And I don't like that for each project I need to run the workflow first to get it's ID and then update it. This makes setting up and copy & pasting configurations a hustle.
from cancel-workflow-action.
The documentation https://developer.github.com/v3/actions/workflows/ makes it sound like workflow id or workflow name is acceptable.
You can also replace :workflow_id with :workflow_file_name. For example, you could use main.yml.
Have you tried doing using it as is?
steps:
- uses: styfle/[email protected]
with:
workflow_id: ${{ github.workflow }}
access_token: ${{ github.token }}
from cancel-workflow-action.
@styfle Thanks, will try and report if it works ...
from cancel-workflow-action.
@styfle It does not work, I've used 0.3.2
of this action, my workflow_id
was set to Alpha Deploy
and I got this error when running this action:
Error while cancelling workflow_id NaN: Invalid value for parameter 'workflow_id': null is NaN
from cancel-workflow-action.
The docs state this:
If the workflow file doesn't specify a name, the value of this property is the full path of the workflow file in the repository.
I don't want to remove my workflow names just to get this working ... (if that even works as the file name also is not a number ...)
from cancel-workflow-action.
Sounds like the culprit here is Number()
.
cancel-workflow-action/src/index.ts
Line 23 in 74c1f40
Removing that to keep it as a string might work assuming the API will accept your "Alpha Deploy" string
from cancel-workflow-action.
Thanks @styfle, but I found another GitHub action that works exactly the way I want to and also doesn't need a workflow_id
that I need to look up. Not sure how that works technically, but maybe you want to have a look:
https://github.com/rokroskar/workflow-run-cleanup-action
from cancel-workflow-action.
Thanks for replies!
Have you tried doing using it as is?
steps: - uses: styfle/[email protected] with: workflow_id: ${{ github.workflow }} access_token: ${{ github.token }}
Would you be opposed to a PR that tried to make the above the default, so that this can be documented and used:
steps:
- uses: styfle/[email protected]
- ...
I feel that this should be possible and documented as a very common use-case, so ppl looking for this don't move on (I truly believe this undocumented use is more common that the use-case you're currently documenting for)
from cancel-workflow-action.
Related Issues (20)
- `Error: Not Found` when running action HOT 3
- Prints a lot details and makes action messier. HOT 4
- GitHub Action marketplace page not updated with latest version info HOT 1
- Cancel action makes our repo test badge "failing" HOT 4
- Fork-based setup seems to cancel itself and not the target workflows HOT 7
- Finding 0 runs HOT 5
- Actions now has built-in cancelation HOT 2
- Does this work on prs? HOT 1
- cancel workflow without email? HOT 2
- possible to cancel previous workflows only when a specific job has not been started? HOT 1
- how to make a cancelled workflow count as skip instead of failed? HOT 3
- Use Node.js v16 HOT 2
- Cancelling the current run HOT 2
- Archive this repo HOT 3
- error message using this step HOT 5
- It should cancel all instances of running workflow when workflow name in workflow_id is specified HOT 3
- Cancel Actions Got A Error HOT 1
- Flag to pick `in_progress`, `waiting` or both to be canceled HOT 2
- Use getBooleanInput to get ignore_sha and all_but_latest HOT 2
- Azure Pipelines alternative HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cancel-workflow-action.