Skip to content

Commit 5603bf0

Browse files
authored
Try to fix permission problems (#18894)
2 parents b9cd807 + fef44ad commit 5603bf0

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

.github/workflows/lts-backport.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
name: Add to backporting project
22

33
on:
4-
pull_request:
5-
types:
6-
- closed
4+
push:
5+
branches:
6+
- main
77

88
jobs:
99
add-to-backporting-project:
1010
if: "github.event.pull_request.merged == true
11-
&& github.event.pull_request.base.ref == 'main'
12-
&& !contains(github.event.pull_request.body, '[Next only]')"
11+
&& !contains(github.event.push.message, '[Next only]')"
1312
runs-on: ubuntu-latest
1413

1514
steps:
@@ -18,7 +17,7 @@ jobs:
1817
fetch-depth: 0
1918
- uses: coursier/cache-action@v6
2019
- uses: VirtusLab/scala-cli-setup@v1.0.5
21-
- run: scala-cli ./project/scripts/addToBackportingProject.scala -- ${{ github.event.pull_request.number }}
20+
- run: scala-cli ./project/scripts/addToBackportingProject.scala -- ${{ github.event.push.after }}
2221
env:
23-
GRAPHQL_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
GRAPHQL_API_TOKEN: ${{ secrets.GRAPHQL_API_TOKEN }}
2423

project/scripts/addToBackportingProject.scala

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,25 @@ case class ID(value: String) derives WrapperVariable
1313
val PROJECT_ID = ID("PVT_kwDOACj3ec4AWSoi")
1414
val FIELD_ID = ID("PVTF_lADOACj3ec4AWSoizgO7uJ4")
1515

16-
@main def run(number: Int) =
17-
val (id, date) = getPrData(number)
16+
@main def run(commitSha: String) =
17+
val (id, date) = getPrData(commitSha)
1818
val newId = addItem(id)
1919
timestampItem(newId, date)
2020

21-
def getPrData(number: Int): (ID, String) =
21+
def getPrData(commitSha: String): (ID, String) =
2222
val res = query"""
23-
|query getPR {
24-
| repository(owner: "lampepfl", name:"dotty") {
25-
| pullRequest(number: $number) {
26-
| id
27-
| mergedAt
23+
|query prForCommit {
24+
| repository(owner:"lampepfl", name:"dotty") {
25+
| object(expression: $commitSha){
26+
| ... on Commit {
27+
| associatedPullRequests(first: 1) {
28+
| nodes {
29+
| number
30+
| id
31+
| mergedAt
32+
| }
33+
| }
34+
| }
2835
| }
2936
| }
3037
|}
@@ -33,7 +40,8 @@ def getPrData(number: Int): (ID, String) =
3340
"DummyUser",
3441
apiToken
3542
)
36-
(ID(res.repository.pullRequest.id), res.repository.pullRequest.mergedAt)
43+
val pr = res.repository.`object`.associatedPullRequests.nodes.head
44+
(ID(pr.id), pr.mergedAt)
3745

3846
def timestampItem(id: ID, date: String) =
3947
query"""

0 commit comments

Comments
 (0)