diff --git a/.github/workflows/lts-backport.yaml b/.github/workflows/lts-backport.yaml index 45638098c836..262b95c4366f 100644 --- a/.github/workflows/lts-backport.yaml +++ b/.github/workflows/lts-backport.yaml @@ -1,15 +1,14 @@ name: Add to backporting project on: - pull_request: - types: - - closed + push: + branches: + - main jobs: add-to-backporting-project: if: "github.event.pull_request.merged == true - && github.event.pull_request.base.ref == 'main' - && !contains(github.event.pull_request.body, '[Next only]')" + && !contains(github.event.push.message, '[Next only]')" runs-on: ubuntu-latest steps: @@ -18,7 +17,7 @@ jobs: fetch-depth: 0 - uses: coursier/cache-action@v6 - uses: VirtusLab/scala-cli-setup@v1.0.5 - - run: scala-cli ./project/scripts/addToBackportingProject.scala -- ${{ github.event.pull_request.number }} + - run: scala-cli ./project/scripts/addToBackportingProject.scala -- ${{ github.event.push.after }} env: - GRAPHQL_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GRAPHQL_API_TOKEN: ${{ secrets.GRAPHQL_API_TOKEN }} diff --git a/project/scripts/addToBackportingProject.scala b/project/scripts/addToBackportingProject.scala index 794975b16b14..37edc8a47efa 100644 --- a/project/scripts/addToBackportingProject.scala +++ b/project/scripts/addToBackportingProject.scala @@ -13,18 +13,25 @@ case class ID(value: String) derives WrapperVariable val PROJECT_ID = ID("PVT_kwDOACj3ec4AWSoi") val FIELD_ID = ID("PVTF_lADOACj3ec4AWSoizgO7uJ4") -@main def run(number: Int) = - val (id, date) = getPrData(number) +@main def run(commitSha: String) = + val (id, date) = getPrData(commitSha) val newId = addItem(id) timestampItem(newId, date) -def getPrData(number: Int): (ID, String) = +def getPrData(commitSha: String): (ID, String) = val res = query""" - |query getPR { - | repository(owner: "lampepfl", name:"dotty") { - | pullRequest(number: $number) { - | id - | mergedAt + |query prForCommit { + | repository(owner:"lampepfl", name:"dotty") { + | object(expression: $commitSha){ + | ... on Commit { + | associatedPullRequests(first: 1) { + | nodes { + | number + | id + | mergedAt + | } + | } + | } | } | } |} @@ -33,7 +40,8 @@ def getPrData(number: Int): (ID, String) = "DummyUser", apiToken ) - (ID(res.repository.pullRequest.id), res.repository.pullRequest.mergedAt) + val pr = res.repository.`object`.associatedPullRequests.nodes.head + (ID(pr.id), pr.mergedAt) def timestampItem(id: ID, date: String) = query"""