From 472428a7ce7270e897448417f4b5c2ee2ac11570 Mon Sep 17 00:00:00 2001 From: Colgrave Date: Wed, 8 Jan 2025 17:31:59 +0000 Subject: [PATCH] Butane example (#66) This PR add an example to translate all Butane config in directory to Ignition config with a simple bash script. Reviewed-on: https://codeberg.org/Codeberg-CI/examples/pulls/66 Reviewed-by: Patrick Schratz Co-authored-by: Colgrave Co-committed-by: Colgrave --- .woodpecker.yaml | 1 + Butane/.woodpecker/butane.yaml | 27 +++++++++++++++++++++++++++ Butane/.woodpecker/script.sh | 16 ++++++++++++++++ README.md | 1 + 4 files changed, 45 insertions(+) create mode 100644 Butane/.woodpecker/butane.yaml create mode 100644 Butane/.woodpecker/script.sh diff --git a/.woodpecker.yaml b/.woodpecker.yaml index a1079f9..8a8a1cf 100644 --- a/.woodpecker.yaml +++ b/.woodpecker.yaml @@ -10,6 +10,7 @@ steps: depends_on: [] image: woodpeckerci/woodpecker-cli:v2.8.2-alpine commands: + - woodpecker-cli lint Butane/.woodpecker/butane.yaml - woodpecker-cli lint C/ - woodpecker-cli lint Docker/ - woodpecker-cli lint Golang/ diff --git a/Butane/.woodpecker/butane.yaml b/Butane/.woodpecker/butane.yaml new file mode 100644 index 0000000..74e04e0 --- /dev/null +++ b/Butane/.woodpecker/butane.yaml @@ -0,0 +1,27 @@ +# butane.yaml +# +# Use a bash script to translate the Butane configs in the current directory to +# the Ignition configs, and push them to the master branch. +# +# [Butane](https://coreos.github.io/butane/) +# [Ignition](https://coreos.github.io/ignition/) +# +# [drone-git-push](https://github.com/appleboy/drone-git-push) + +when: + branch: main + event: [push, pull_request] + +steps: + - name: build + image: quay.io/coreos/butane:release + commands: + - bash ./script.sh + + - name: push + image: docker.io/appleboy/drone-git-push + settings: + ssh_key: + from_secret: ssh_key + remote: git@codeberg.org:.git + branch: main diff --git a/Butane/.woodpecker/script.sh b/Butane/.woodpecker/script.sh new file mode 100644 index 0000000..55f00c1 --- /dev/null +++ b/Butane/.woodpecker/script.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# loop through all butane files in the current directory +for i in *.bu ; do + # extract filename without extension + name=${i%.bu} + + # use butane to convert the YAML file into an Ignition configuration + butane -ps ${i} -o ${name}.ign + + if [ $? -eq 0 ]; then + echo "Converted ${i} to ${name}.ign successfully" + else + echo "Error converting ${i}" + fi +done diff --git a/README.md b/README.md index e64106b..29a6b08 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ Pull requests are welcome! | Link | Language | Build System | Comments | | :--------------------------------------------------------------------------- | :---------- | :------------------ | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [Butane/.woodpecker/butane.yaml](Butane/.woodpecker/butane.yaml) | Bash | --- | Translate Butane configs into Ignition configs with a simple bash script. | | [C/.woodpecker/make.yaml](C/.woodpecker/make.yaml) | C | Make | Simple ci for building a Make based C project | | [C/.woodpecker/meson.yaml](C/.woodpecker/meson.yaml) | C/C++ | meson | CI for meson-based projects. | | [C/.woodpecker/meson-android.yaml](C/.woodpecker/meson-android.yaml) | C/C++ | meson + Android NDK | CI for meson-based projects cross-compiling to Android NDK. |