Skip to content

Commit 232cd1b

Browse files
committed
operator: add ci for build and check-bundle
1 parent f34355e commit 232cd1b

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

.github/workflows/build.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ jobs:
2626
- image_name: jumpstarter-dev/jumpstarter-operator
2727
dockerfile: Dockerfile.operator
2828
context: .
29+
- image_name: jumpstarter-dev/jumpstarter-operator-bundle
30+
dockerfile: bundle.Dockerfile
31+
context: deploy/operator
2932
steps:
3033
- name: Checkout repository
3134
uses: actions/checkout@v4
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Check Bundle
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
- 'release-*'
7+
8+
jobs:
9+
check-bundle:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Set up Go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version: 1.24
21+
22+
- name: Cache Go modules
23+
uses: actions/cache@v4
24+
with:
25+
path: |
26+
~/.cache/go-build
27+
~/go/pkg/mod
28+
key: ${{ runner.os }}-go-${{ hashFiles('go.mod', 'deploy/operator/go.mod') }}
29+
restore-keys: |
30+
${{ runner.os }}-go-
31+
32+
- name: Cache bin directory (root)
33+
uses: actions/cache@v4
34+
with:
35+
path: bin/
36+
key: ${{ runner.os }}-bin-${{ hashFiles('go.mod') }}
37+
restore-keys: |
38+
${{ runner.os }}-bin-
39+
40+
- name: Cache bin directory (deploy/operator)
41+
uses: actions/cache@v4
42+
with:
43+
path: deploy/operator/bin/
44+
key: ${{ runner.os }}-operator-bin-${{ hashFiles('deploy/operator/go.mod') }}
45+
restore-keys: |
46+
${{ runner.os }}-operator-bin-
47+
48+
- name: Get version
49+
run: |
50+
if [ "${{ github.event_name }}" == "pull_request" ]; then
51+
BASE_BRANCH="${{ github.base_ref }}"
52+
if [ "$BASE_BRANCH" == "main" ]; then
53+
TAG="latest"
54+
elif [[ "$BASE_BRANCH" =~ ^release- ]]; then
55+
TAG="$BASE_BRANCH"
56+
else
57+
echo "::error::Unknown base branch: $BASE_BRANCH"
58+
exit 1
59+
fi
60+
else
61+
echo "::error::Unsupported event: ${{ github.event_name }}"
62+
exit 1
63+
fi
64+
echo "TAG=${TAG}" >> $GITHUB_ENV
65+
echo "TAG=${TAG}"
66+
67+
- name: Run make bundle
68+
working-directory: deploy/operator
69+
run: |
70+
make bundle IMG="quay.io/jumpstarter-dev/jumpstarter-operator:${TAG}"
71+
72+
- name: Check for uncommitted changes
73+
run: |
74+
if [ -n "$(git status --porcelain)" ]; then
75+
# Get diff and check if it only contains createdAt timestamp changes
76+
DIFF=$(git diff)
77+
# Filter out createdAt timestamp lines and context lines, check if any actual changes remain
78+
FILTERED_DIFF=$(echo "$DIFF" | grep -vE '^(---|\+\+\+|@@|index|diff)' | grep -vE '^[+-].*createdAt:.*[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z' || true)
79+
# Check if there are any non-timestamp, non-context changes
80+
if [ -n "$FILTERED_DIFF" ] && [ -n "$(echo "$FILTERED_DIFF" | grep -E '^[+-]' || true)" ]; then
81+
echo "::error::Uncommitted changes detected after running 'make bundle'. Please commit all bundle changes before pushing."
82+
echo "::error::This can be done by running 'make bundle IMG=\"quay.io/jumpstarter-dev/jumpstarter-operator:${TAG}\""
83+
git diff
84+
exit 1
85+
else
86+
echo "Only timestamp changes detected (ignored). Bundle files are up to date."
87+
# Reset the timestamp changes to keep the repo clean
88+
git checkout -- .
89+
fi
90+
else
91+
echo "No uncommitted changes detected. Bundle files are up to date."
92+
fi
93+
- name: Run make build-installer
94+
working-directory: deploy/operator
95+
run: |
96+
git stash
97+
make build-installer
98+
99+
- name: Check for uncommitted changes after build-installer
100+
run: |
101+
if [ -n "$(git status --porcelain)" ]; then
102+
echo "::error::Uncommitted changes detected after running 'make build-installer'. Please commit all installer changes before pushing."
103+
echo "::error::This can be done by running 'make build-installer'"
104+
git diff
105+
exit 1
106+
else
107+
echo "No uncommitted changes detected. Installer files are up to date."
108+
fi
109+

0 commit comments

Comments
 (0)