-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathregenerate-yarn-lock.main.kts
More file actions
executable file
·68 lines (65 loc) · 2.55 KB
/
Copy pathregenerate-yarn-lock.main.kts
File metadata and controls
executable file
·68 lines (65 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env kotlin
@file:Repository("https://repo1.maven.org/maven2/")
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:3.7.0")
@file:Repository("https://bindings.krzeminski.it")
@file:DependsOn("actions:checkout:v7")
import io.github.typesafegithub.workflows.domain.RunnerType
import io.github.typesafegithub.workflows.domain.triggers.IssueComment
import io.github.typesafegithub.workflows.dsl.expressions.expr
import io.github.typesafegithub.workflows.dsl.workflow
import io.github.typesafegithub.workflows.yaml.CheckoutActionVersionSource
import io.github.typesafegithub.workflows.yaml.DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG
import io.github.typesafegithub.workflows.actions.actions.Checkout
workflow(
name = "Regenerate yarn.lock",
on = listOf(
IssueComment()
),
consistencyCheckJobConfig = DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG.copy(
checkoutActionVersion = CheckoutActionVersionSource.InferFromClasspath(),
),
sourceFile = __FILE__,
) {
job(
id = "regenerate-yarn-lock",
runsOn = RunnerType.UbuntuLatest,
`if` = expr("github.event.issue.pull_request")
) {
run(
name = "Print comment",
command = "echo \"Comment: '${expr("github.event.comment.body")}'\"",
)
uses(
action = Checkout(),
`if` = expr("github.event.comment.body == 'regenerate-lock'"),
)
run(
name = "Checkout PR branch",
command = "gh pr checkout ${expr("github.event.issue.number")}",
env = mapOf("GH_TOKEN" to expr("github.token")),
`if` = expr("github.event.comment.body == 'regenerate-lock'"),
)
run(
name = "Regenerate yarn.lock",
command = "./gradlew kotlinUpgradeYarnLock",
`if` = expr("github.event.comment.body == 'regenerate-lock'"),
)
run(
name = "Configure git",
command = """
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
""".trimIndent(),
`if` = expr("github.event.comment.body == 'regenerate-lock'"),
)
run(
name = "Commit and push yarn.lock",
command = """
git add kotlin-js-store/yarn.lock
git diff --cached --exit-code || git commit -m "Regenerate yarn.lock"
git push
""".trimIndent(),
`if` = expr("github.event.comment.body == 'regenerate-lock'"),
)
}
}