Skip to content

Commit

Permalink
Add workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
krzema12 committed Dec 20, 2023
1 parent 002888d commit 5c6e541
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/update-metadata.main.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env kotlin
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.7.0")

import io.github.typesafegithub.workflows.domain.RunnerType
import io.github.typesafegithub.workflows.dsl.workflow
import io.github.typesafegithub.workflows.domain.triggers.Push
import io.github.typesafegithub.workflows.yaml.writeToFile

workflow(
name = "Update metadata",
sourceFile = __FILE__.toPath(),
on = listOf(Push(branches = listOf("main", "generate-metadata"))),
) {
job(
id = "generate",
runsOn = RunnerType.UbuntuLatest,
) {
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()
)
run(
name = "Run generation logic",
command = "scripts/updateMetadata.main.kts",
)
run(
name = "Push new commit",
command = "git push",
)
}
}.writeToFile()
40 changes: 40 additions & 0 deletions .github/workflows/update-metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This file was generated using Kotlin DSL (.github/workflows/update-metadata.main.kts).
# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file.
# Generated with https://github.com/typesafegithub/github-workflows-kt

name: 'Update metadata'
on:
push:
branches:
- 'main'
- 'generate-metadata'
jobs:
check_yaml_consistency:
name: 'Check YAML consistency'
runs-on: 'ubuntu-latest'
steps:
- id: 'step-0'
name: 'Check out'
uses: 'actions/checkout@v4'
- id: 'step-1'
name: 'Execute script'
run: 'rm ''.github/workflows/update-metadata.yaml'' && ''.github/workflows/update-metadata.main.kts'''
- id: 'step-2'
name: 'Consistency check'
run: 'git diff --exit-code ''.github/workflows/update-metadata.yaml'''
generate:
runs-on: 'ubuntu-latest'
needs:
- 'check_yaml_consistency'
steps:
- id: 'step-0'
name: 'Configure git'
run: |-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
- id: 'step-1'
name: 'Run generation logic'
run: 'scripts/updateMetadata.main.kts'
- id: 'step-2'
name: 'Push new commit'
run: 'git push'

0 comments on commit 5c6e541

Please sign in to comment.