Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Set different rules for different workflows #2

Open
JohnyP36 opened this issue Mar 12, 2022 · 2 comments
Open

Set different rules for different workflows #2

JohnyP36 opened this issue Mar 12, 2022 · 2 comments

Comments

@JohnyP36
Copy link

How can I apply different settings for each workflow I have?

So, I have 4 workflows.
I want workflow 1 to be deleted after 14 days and keep a minimum of 7;
I want workflow 2 to be deleted after 63 days and keep a minimum of 75;
etc...

How can I manage this in one file? Or do I need 4 workflows to deleted the other 4 workflows?

@stefan-stanescu-maersk
Copy link
Contributor

stefan-stanescu-maersk commented Mar 12, 2022

Hi Johny

You should be able to do it in one workflow. Just call the action multiple times:

steps:
  - name: Delete workflow runs 1
    uses: MajorScruffy/delete-workflow-runs
    id: delete-workflow-runs-1
    with:
      repository: MajorScruffy/delete-workflow-runs   # replace this with your own repository
      workflow: .github/workflows/workflow1.yml  # replace this with the path to your first workflow
      older-than-seconds: 1209600
      maximum-workflow-runs-to-keep: 7
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      
  - name: Delete workflow runs 2
    uses: MajorScruffy/delete-workflow-runs
    id: delete-workflow-runs-2
    with:
      repository: MajorScruffy/delete-workflow-runs   # replace this with your own repository
      workflow: .github/workflows/workflow2.yml  # replace this with the path to your second workflow
      older-than-seconds: 5443200
      maximum-workflow-runs-to-keep: 75
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

You could call the action at the start of each workflow, so that each workflow takes care of its own clean-up, or you could have a separate workflow that runs on a schedule and calls the action once for each workflow. That's up to you.

@JohnyP36
Copy link
Author

JohnyP36 commented Mar 12, 2022

Thanks, it worked.

The only thing is: I got a warning
image

Permalink of the file I made

It seems it doesn't recognize the maximum-workflow-runs-to-keep variable...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants