Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(actions): auto-label PRs that close issues. #27047

Closed
wants to merge 14 commits into from

Conversation

rusackas
Copy link
Member

@rusackas rusackas commented Feb 8, 2024

SUMMARY

Just a theory, but this should look at any given PR and check the description body to see if it auto-closes any issues. If so, label the thing! This should help us prioritize PRs that will also help whittle the Issues backlog.

This also looks at more triggers (including "edited") to run the action on PR description edits. The jobs in the action can be triggered by subsets of these actions (e.g. the main labeler doesn't run on PR description edits).

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

Go ahead! Edit this PR description, and look for the addition/removal of the label!

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

- name: Auto-label PRs
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
Copy link
Member

Choose a reason for hiding this comment

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

don't think we have access to secrets when triggering by pull_request. it works on PRs that don't come from forks

Copy link
Member Author

Choose a reason for hiding this comment

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

I had read somewhere that the repo does provide a generated GITHUB_TOKEN with limited authority (tagging, commenting, etc) on forks, so this should work.

I can add a secrets check to skip the job if the secret is not available, but I think that secret always is.

Copy link
Member Author

Choose a reason for hiding this comment

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

I kinda want to merge it and test the theory. I can add the secret check to skip the action if it doesn't work.

Copy link
Member

@dpgaspar dpgaspar Feb 8, 2024

Choose a reason for hiding this comment

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

Copy link
Member Author

@rusackas rusackas Feb 8, 2024

Choose a reason for hiding this comment

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

Hmm... and I see the labeller action above the one I'm adding here has

   permissions:
      contents: read
      pull-requests: write

... but I'm (a) not sure if that job works on forks (maybe that's broken too?), or (b) if we can elevate the default permissions like that.

I'm not sure yet if there's a better approach here, or if there's a way to skip this action for forks if we can't make it work.

Copy link
Member

Choose a reason for hiding this comment

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

Curious to know if we are moving forward with this as I am planning to consider it for a long-term proposal to improve the management of the backlog

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, I sure WANT to merge it, but I'm not sure how to proceed. Maybe @mistercrunch knows how to unblock this thing :P

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

In that case, what happens is it will trigger the action that's defined on the main target repo's branch, and say if you do a checkout it would be the target's ref not the PR one. Does that work here? Actually do you need to checkout?

label-auto-closing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure you need to checkout here?

@rusackas rusackas closed this Aug 3, 2024
@mistercrunch mistercrunch deleted the label-issue-closing-PRs branch November 25, 2024 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants