|
| 1 | +#!/usr/bin/env kotlin |
| 2 | +@file:Repository("https://repo1.maven.org/maven2/") |
| 3 | +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.15.0") |
| 4 | + |
| 5 | +@file:Repository("https://github-workflows-kt-bindings.colman.com.br/binding/") |
| 6 | +@file:DependsOn("actions:checkout:v4") |
| 7 | +@file:DependsOn("gradle:actions__setup-gradle:v3") |
| 8 | + |
| 9 | +import io.github.typesafegithub.workflows.actions.actions.Checkout |
| 10 | +import io.github.typesafegithub.workflows.actions.gradle.ActionsSetupGradle |
| 11 | +import io.github.typesafegithub.workflows.domain.RunnerType |
| 12 | +import io.github.typesafegithub.workflows.domain.triggers.WorkflowDispatch |
| 13 | +import io.github.typesafegithub.workflows.dsl.workflow |
| 14 | +import io.github.typesafegithub.workflows.yaml.writeToFile |
| 15 | + |
| 16 | +workflow( |
| 17 | + name = "Update dist", |
| 18 | + on = listOf( |
| 19 | + WorkflowDispatch(), |
| 20 | + ), |
| 21 | + sourceFile = __FILE__.toPath(), |
| 22 | +) { |
| 23 | + job( |
| 24 | + id = "build", |
| 25 | + runsOn = RunnerType.UbuntuLatest, |
| 26 | + ) { |
| 27 | + uses(action = Checkout()) |
| 28 | + uses(action = ActionsSetupGradle()) |
| 29 | + run(command = "./gradlew build") |
| 30 | + |
| 31 | + run( |
| 32 | + name = "Regenerate the contents of dist directory", |
| 33 | + command = """ |
| 34 | + set -euxo pipefail |
| 35 | +
|
| 36 | + rm -rf dist |
| 37 | + unzip -qq build/distributions/github-actions-typing.zip -d dist |
| 38 | + rm -rf dist/github-actions-typing/bin |
| 39 | + """.trimIndent() |
| 40 | + ) |
| 41 | + |
| 42 | + run( |
| 43 | + name = "Configure git", |
| 44 | + command = """ |
| 45 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 46 | + git config user.name "github-actions[bot]" |
| 47 | + """.trimIndent() |
| 48 | + ) |
| 49 | + |
| 50 | + run( |
| 51 | + name = "Commit changes", |
| 52 | + command = """ |
| 53 | + git add . |
| 54 | + git commit -m "Update dist" |
| 55 | + """.trimIndent() |
| 56 | + ) |
| 57 | + |
| 58 | + run( |
| 59 | + name = "Push commit", |
| 60 | + command = "git push", |
| 61 | + ) |
| 62 | + } |
| 63 | +}.writeToFile() |
0 commit comments