Skip to content

Commit

Permalink
Try to fix permission problems (#18894)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kordyjan authored Nov 10, 2023
2 parents b9cd807 + fef44ad commit 5603bf0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/lts-backport.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -18,7 +17,7 @@ jobs:
fetch-depth: 0
- uses: coursier/cache-action@v6
- uses: VirtusLab/[email protected]
- 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 }}

26 changes: 17 additions & 9 deletions project/scripts/addToBackportingProject.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
| }
| }
| }
| }
| }
|}
Expand All @@ -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"""
Expand Down

0 comments on commit 5603bf0

Please sign in to comment.