Giter Club home page Giter Club logo

Comments (15)

styfle avatar styfle commented on August 14, 2024 3

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.

styfle avatar styfle commented on August 14, 2024 2

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.

patcon avatar patcon commented on August 14, 2024 1

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.

patcon avatar patcon commented on August 14, 2024 1

@Jeehut

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.

Wandalen avatar Wandalen commented on August 14, 2024 1

+1 maybe we could change the workflow_id parameter to be optional

from cancel-workflow-action.

styfle avatar styfle commented on August 14, 2024 1

Thanks, take a look at https://github.com/styfle/cancel-workflow-action/releases/tag/0.4.0

from cancel-workflow-action.

styfle avatar styfle commented on August 14, 2024

Are you suggesting the same as #2 or is this a different feature request?

from cancel-workflow-action.

Jeehut avatar Jeehut commented on August 14, 2024

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.

styfle avatar styfle commented on August 14, 2024

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.

Jeehut avatar Jeehut commented on August 14, 2024

@styfle Thanks, will try and report if it works ...

from cancel-workflow-action.

Jeehut avatar Jeehut commented on August 14, 2024

@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.

Jeehut avatar Jeehut commented on August 14, 2024

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.

styfle avatar styfle commented on August 14, 2024

Sounds like the culprit here is Number().

const workflow_ids = workflow_id.replace(/\s/g, '').split(',').map(s => Number(s));

Removing that to keep it as a string might work assuming the API will accept your "Alpha Deploy" string

from cancel-workflow-action.

Jeehut avatar Jeehut commented on August 14, 2024

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.

patcon avatar patcon commented on August 14, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.