|
| 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 | +
|
| 94 | + - name: Ensure clean state before build-installer |
| 95 | + run: | |
| 96 | + # Reset any remaining changes from root |
| 97 | + git checkout -- . || true |
| 98 | +
|
| 99 | + - name: Run make build-installer |
| 100 | + working-directory: deploy/operator |
| 101 | + run: | |
| 102 | + make build-installer |
| 103 | +
|
| 104 | + - name: Check for uncommitted changes after build-installer |
| 105 | + run: | |
| 106 | + if [ -n "$(git status --porcelain)" ]; then |
| 107 | + echo "::error::Uncommitted changes detected after running 'make build-installer'. Please commit all installer changes before pushing." |
| 108 | + echo "::error::This can be done by running 'make build-installer'" |
| 109 | + git diff |
| 110 | + exit 1 |
| 111 | + else |
| 112 | + echo "No uncommitted changes detected. Installer files are up to date." |
| 113 | + fi |
| 114 | +
|
0 commit comments