Giter Site home page Giter Site logo

Comments (4)

joerick avatar joerick commented on June 3, 2024

from pr-labels-action.

victornvg avatar victornvg commented on June 3, 2024

@joerick for example
I create PR - 1 with label minor, when trigger github action on this PR - 1, joerick/[email protected] will return the correct label minor. Everything works fine.
But when I merge this PR - 1 to default branch (main in this case), and I have the workflow trigger push event on main, joerick/[email protected] won't return the label from merged PR - 1 (only show Not a pull request)

This is not a bug. Just a request to support another case, that joerick/[email protected] can return the correct label from merged PR - 1 (minor in this case) when pushing PR - 1 to default branch.

from pr-labels-action.

weibullguy avatar weibullguy commented on June 3, 2024

@victornvg I too was wanting to do this, but I don't think it's easily done using the REST API. A push is a commit, so the payload when using the REST API has no information related to the PR. It's distinctly possible I have no idea what I'm talking about, but you can read about commits (pushes) here --> https://docs.github.com/en/rest/reference/commits#get-a-commit There is an example of the returned payload and you can see there is no information related to the PR. A PR requires a push, but a push doesn't require a PR, so it makes some intuitive sense.

It looks like you might be able to work backwards to the PR using the commit's ref. I don't know how difficult that would be, but it seems mildly convoluted to me. Again, it's distinctly possible I have no idea what I'm talking about.

That said, it looks like the GraphQL API makes this easier. One of the fields in the commit object is associatedPullRequests. You can see that here --> https://docs.github.com/en/graphql/reference/objects#commit If you poke around a bit in the GraphQL API documentation, you'll see there is a labels field associated with the PullRequest object.

from pr-labels-action.

deejgregor avatar deejgregor commented on June 3, 2024

I suspect you can accomplish what you are looking for by matching on a pull request of type closed that has been merged.

For example, this on block:

on:
  pull_request:
    types:
    - closed
    branches:
    - main

And in each job, make sure you match on pull requests that have been merged (because you probably won't want to match pull requests that have been closed without merging):

if: github.event.pull_request.merged == true

See this for more information: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-your-pull_request-workflow-when-a-pull-request-merges

from pr-labels-action.

Related Issues (8)

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.