Open lukonjun opened 2 years ago
Would this feature allow you to filter out those PRs? https://github.com/argoproj/argo-cd/pull/9312
Hi @crenshaw-dev, unsure if this allows to ignore labels like dependencies
and select everything else, can you maybe elaborate on the feature you are developing?
@crenshaw-dev I also think the above issue doesn't fix one scenario: My PRs are automatically labeled. And if a PR is stale, I'll also label that PR with a stale tag (using this). It would be nice if we could exclude PRs with certain tags from the PR generator, so that we can get stale PRs to be uninstalled. Something like:
spec:
generators:
- pullRequest:
...
labels:
- auto-deploy
ignore-labels:
- stale
@mulhotavares This is something that I would really appreciate also. Have you found any support or workaround for this scenerio?
@mulhotavares This is something that I would really appreciate also. Have you found any support or workaround for this scenerio?
No, haven't found any workaround yet. A workaround would be to remove labels once a PR is stale, but I can't find an easy way to automate that.
Hi @jankaderabek, @mulhotavares we actually found a workaround, however it is a bit hacky as it needs additional configuration in your GitHub Actions. Every time we want to create an Argo Application via PR generator we simply tag this branch. This is a workflow you can just add to your GitHub Actions
name: Label pull-request
on:
workflow_call:
inputs:
pr_number:
description: The pull-request number to label.
required: true
type: string
pr_label:
description: The label to be add to the pull-request.
required: true
type: string
jobs:
add_label:
name: Label pull-request
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Label pull-request
run: gh pr edit ${{ inputs.pr_number }} --add-label ${{ inputs.pr_label }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Now in your ApplicationSet you define to only look for certain Labels
spec:
generators:
- pullRequest:
github:
owner: example-owner
repo: example-repo
tokenRef:
secretName: github-token
key: token
labels:
- preview
requeueAfterSeconds: 120
This way you will only create Argo Applications for Branches with the tag preview. @crenshaw-dev I think however that implementing something like ignore-labels
and would make more people use this great feature of pull request generator
@lukonjun I already use labels as I mentioned in my previous message. The problem is that sometimes we may have conflicting labels. And I don't know of any way of removing a label if it conflicts with others...
More specifically, in my case I also label PRs as stale. And I would like to delete their respective applications once they are marked as so.
@mulhotavares upppps, missed that, sorry. Yea for that case support for ignoring labels would be great!
@lukonjun No problem at all. You actually gave me some ideas. I didn't know there was such a thing as gh pr
CLI.
If that CLI allows us to query the tags for the PR, we could implement some custom logic to add and remove tags... so if I find the stale
label, I could remove the auto-deploy
one...
Apparently now we have a workaround on this: https://github.com/actions/stale/releases/tag/v8.0.0 We can use that action to remove the labels used by the ApplicationSet. So although argocd can't ignore labels, we can at least remove the labels for the PRs we want to ignore.
Summary
Following up on this question https://github.com/argoproj/argo-cd/discussions/9418. It would be great if the Pull Request Generator for ApplicationSets has the functionality to ignore certain PRs. Currently only setting labels that filter PRs that you want to target is possible.
Motivation
At my company we use Dependabot intensively and updates run on a weekly basis, often creating up to 30 PRs in each Repository. We do not want to create an Argo Application for every Dependabot PR that is created, however we also do not want to manually label branches to boot a preview environment.
Proposal
Add a field to ignore labels that wont trigger the creation of an argo application. Extending this example from the docs https://argocd-applicationset.readthedocs.io/en/stable/Generators-Pull-Request/