Skip to content

update label check for dependabot action#5194

Merged
emmyoop merged 1 commit intomainfrom
er/dependabot-changelog-fix
May 2, 2022
Merged

update label check for dependabot action#5194
emmyoop merged 1 commit intomainfrom
er/dependabot-changelog-fix

Conversation

@emmyoop
Copy link
Copy Markdown
Member

@emmyoop emmyoop commented Apr 29, 2022

Fix small bug where action to add changelog file never kicked off if the label was added before PR creation. It still worked if you added label after creation.

test to add label after PR creation

test to add label before PR creation

This should eventually be moved over to shared actions since we will need it across multiple repos.

Checklist

@emmyoop emmyoop added the Skip Changelog Skips GHA to check for changelog file label Apr 29, 2022
@emmyoop emmyoop requested a review from leahwicz as a code owner April 29, 2022 14:06
@cla-bot cla-bot Bot added the cla:yes label Apr 29, 2022
@emmyoop emmyoop changed the title update label check update label check for dependabot action Apr 29, 2022

jobs:
dependency_changelog:
if: ${{ github.event.label.name == 'dependencies' }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory this would also kick-off if another label was added after the dependencies label, but nothing would happen since the changelog file would already exist, correct?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leahwicz, correct. There's not a way I know of to only run if a specific label is added. So this will run, then it hits a check for if the changelog exists:

- name: Check if changelog file exists already
# if there's already a changelog entry, don't add another one!
# https://github.com/marketplace/actions/paths-changes-filter
# For each filter, it sets output variable named by the filter to the text:
# 'true' - if any of changed files matches any of filter rules
# 'false' - if none of changed files matches any of filter rules
# also, returns:
# `changes` - JSON array with names of all filters matching any of the changed files
uses: dorny/paths-filter@v2
id: changelog_check
with:
token: ${{ secrets.GITHUB_TOKEN }}
filters: |
exists:
- added: '.changes/unreleased/**.yaml'

And should the pass on adding another one.

I could add another if to check if the action was labeled and the label was dependencies. IT would still trigger the workflow but would fail sooner. Something like this (syntax may be wrong):

jobs:
  dependency_changelog:
    if: |
      (${{ github.event == 'opened' }} && "contains(github.event.pull_request.labels.*.name, 'dependencies')")
      || (${{ github.event == 'labeled' }} && ${{ github.event.label.name == 'dependencies' }})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah what you have is fine then since it does check for the changelog existing so the danger of the workflow running multiple times is accounted for. 🚢 it!

@emmyoop emmyoop merged commit 96f063e into main May 2, 2022
@emmyoop emmyoop deleted the er/dependabot-changelog-fix branch May 2, 2022 16:51
agoblet pushed a commit to BigDataRepublic/dbt-core that referenced this pull request May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla:yes Skip Changelog Skips GHA to check for changelog file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants