-
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
- Loading branch information
Showing
2 changed files
with
96 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,72 @@ | ||
//> 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") | ||
|
||
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: 17570) { | ||
| 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: "PVT_kwDOACj3ec4AWSoi", | ||
| itemId: $id, | ||
| fieldId: "PVTF_lADOACj3ec4AWSoizgO7uJ4", | ||
| 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: "PVT_kwDOACj3ec4AWSoi", | ||
| contentId: $id | ||
| }) { | ||
| item { | ||
| id | ||
| } | ||
| } | ||
|} | ||
""".send( | ||
uri"https://api.github.com/graphql", | ||
"Kordyjan", | ||
apiToken | ||
) | ||
ID(res.addProjectV2ItemById.item.id) |