-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflow adding to backport project (#18772)
This adds a simple workflow that will add each PR merged to `main` to the lts-backporting project. The workflow can be skipped by using a following tag (used here intentionally): [Next only]
- Loading branch information
Showing
2 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Add to backporting project | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
|
||
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]')" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: coursier/cache-action@v6 | ||
- uses: VirtusLab/[email protected] | ||
- run: scala-cli ./project/scripts/addToBackportingProject.scala -- ${{ github.event.pull_request.number }} | ||
env: | ||
GRAPHQL_API_TOKEN: ${{ secrets.GRAPHQL_API_TOKEN }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
//> using scala 3.3.1 | ||
//> using toolkit 0.2.1 | ||
//> using lib pro.kordyjan::pytanie:0.1.6 | ||
|
||
import pytanie.* | ||
import sttp.client4.* | ||
|
||
lazy val apiToken = | ||
System.getenv("GRAPHQL_API_TOKEN") | ||
|
||
val PROJECT_ID: String = "PVT_kwDOACj3ec4AWSoi" | ||
val FIELD_ID: String = "PVTF_lADOACj3ec4AWSoizgO7uJ4" | ||
|
||
case class ID(value: String) derives WrapperVariable | ||
|
||
@main def run(number: Int) = | ||
val (id, date) = getPrData(number) | ||
val newId = addItem(id) | ||
timestampItem(newId, date) | ||
|
||
def getPrData(number: Int): (ID, String) = | ||
val res = query""" | ||
|query getPR { | ||
| repository(owner: "lampepfl", name:"dotty") { | ||
| pullRequest(number: $number) { | ||
| id | ||
| mergedAt | ||
| } | ||
| } | ||
|} | ||
""".send( | ||
uri"https://api.github.com/graphql", | ||
"Kordyjan", | ||
apiToken | ||
) | ||
(ID(res.repository.pullRequest.id), res.repository.pullRequest.mergedAt) | ||
|
||
def timestampItem(id: ID, date: String) = | ||
query""" | ||
|mutation editField { | ||
| updateProjectV2ItemFieldValue(input: { | ||
| projectId: $PROJECT_ID, | ||
| itemId: $id, | ||
| fieldId: $FIELD_ID, | ||
| value: { text: $date } | ||
| }) { | ||
| projectV2Item { | ||
| updatedAt | ||
| } | ||
| } | ||
|} | ||
""".send( | ||
uri"https://api.github.com/graphql", | ||
"Kordyjan", | ||
apiToken | ||
) | ||
|
||
def addItem(id: ID) = | ||
val res = query""" | ||
|mutation addItem { | ||
| addProjectV2ItemById(input: { | ||
| projectId: $PROJECT_ID, | ||
| contentId: $id | ||
| }) { | ||
| item { | ||
| id | ||
| } | ||
| } | ||
|} | ||
""".send( | ||
uri"https://api.github.com/graphql", | ||
"Kordyjan", | ||
apiToken | ||
) | ||
ID(res.addProjectV2ItemById.item.id) |