From 98744fb1316eb40135767af2a8e0ea7154851c72 Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Sun, 9 Feb 2025 18:52:05 +0100 Subject: [PATCH 1/3] Add a CI job for pattern.sh --- .github/workflows/pattern-sh-ci.yml | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/pattern-sh-ci.yml diff --git a/.github/workflows/pattern-sh-ci.yml b/.github/workflows/pattern-sh-ci.yml new file mode 100644 index 00000000..9aa4cf4e --- /dev/null +++ b/.github/workflows/pattern-sh-ci.yml @@ -0,0 +1,41 @@ +name: Run Bash Script on Multiple Distributions + +on: + push: + branches: + - main + pull_request: + +jobs: + run-script: + name: Run Bash Script + strategy: + matrix: + # Fedora is not an option yet + os: [ubuntu-latest, ubuntu-22.04] + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Install Podman on Ubuntu + if: contains(matrix.os, 'ubuntu') + run: | + sudo apt-get update + sudo apt-get install -y podman + + # Currently we do not do MacOSX as it is not free, maybe in the future + # - name: Install Podman on macOS + # if: contains(matrix.os, 'macos') + # run: | + # brew install podman + # podman machine init + # podman machine start + + - name: Verify Podman Installation + run: podman --version + + - name: Run pattern.sh script + run: | + ./scripts/pattern-util.sh make validate-origin From 7c950f678f1dd71acffa80b69dfba212a696eb04 Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Mon, 10 Feb 2025 09:15:27 +0100 Subject: [PATCH 2/3] Allow TARGET_BRANCH to be overridden --- .github/workflows/pattern-sh-ci.yml | 1 + Makefile | 2 +- scripts/pattern-util.sh | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pattern-sh-ci.yml b/.github/workflows/pattern-sh-ci.yml index 9aa4cf4e..92eadfd5 100644 --- a/.github/workflows/pattern-sh-ci.yml +++ b/.github/workflows/pattern-sh-ci.yml @@ -38,4 +38,5 @@ jobs: - name: Run pattern.sh script run: | + export TARGET_BRANCH=main ./scripts/pattern-util.sh make validate-origin diff --git a/Makefile b/Makefile index fc10236e..4e977e10 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ TARGET_ORIGIN ?= origin # This is because we expect to use tokens for repo authentication as opposed to SSH keys TARGET_REPO=$(shell git ls-remote --get-url --symref $(TARGET_ORIGIN) | sed -e 's/.*URL:[[:space:]]*//' -e 's%^git@%%' -e 's%^https://%%' -e 's%:%/%' -e 's%^%https://%') # git branch --show-current is also available as of git 2.22, but we will use this for compatibility -TARGET_BRANCH=$(shell git rev-parse --abbrev-ref HEAD) +TARGET_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD) UUID_FILE ?= ~/.config/validated-patterns/pattern-uuid UUID_HELM_OPTS ?= diff --git a/scripts/pattern-util.sh b/scripts/pattern-util.sh index 27b30229..8258d469 100755 --- a/scripts/pattern-util.sh +++ b/scripts/pattern-util.sh @@ -88,6 +88,7 @@ podman run -it --rm --pull=newer \ -e EXTRA_PLAYBOOK_OPTS \ -e TARGET_ORIGIN \ -e TARGET_SITE \ + -e TARGET_BRANCH \ -e NAME \ -e TOKEN_SECRET \ -e TOKEN_NAMESPACE \ From 46af2026b3c8221b143580826bc6c3f800c449f0 Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Mon, 10 Feb 2025 09:17:50 +0100 Subject: [PATCH 3/3] Restrict GH actions only to certain files --- .github/workflows/pattern-sh-ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/pattern-sh-ci.yml b/.github/workflows/pattern-sh-ci.yml index 92eadfd5..ed0e6a07 100644 --- a/.github/workflows/pattern-sh-ci.yml +++ b/.github/workflows/pattern-sh-ci.yml @@ -2,9 +2,15 @@ name: Run Bash Script on Multiple Distributions on: push: + paths: + - "scripts/**" + - "Makefile" branches: - main pull_request: + paths: + - "scripts/**" + - "Makefile" jobs: run-script: