Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: CI
# Jobs in this workflow are enforced as required status checks via branch protection on main.

on:
push:
pull_request:
# 'edited' is included so commitlint re-runs when PR title changes (used as squash commit message)
types: [opened, edited, synchronize, reopened]

permissions:
contents: read
pull-requests: read


jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod

- name: Check linter configuration
run: make lint-config

- name: Run linter
uses: golangci/golangci-lint-action@v9
with:
version: v2.11.4

test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod

- name: Run tests
run: |
go mod tidy
make test

codegen-check:
name: Verify Generated Code
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod

- name: Run code generation
run: |
make manifests
make generate
make crd-docs

- name: Check for uncommitted changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "::error::Generated code is out of date. Please run 'make manifests generate crd-docs' and commit the changes."
echo ""
echo "Changed files:"
git status --short
echo ""
echo "Diff:"
git diff
exit 1
fi
echo "Generated code is up to date."

commitlint:
name: Validate Commit Messages
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version

- name: Install commitlint
run: npm ci

- name: Lint commits
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

test-e2e:
name: Test E2E
runs-on: ubuntu-latest
if: false # disabled until fixed
steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod

- name: Install kind
run: |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-$(go env GOARCH)
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind

- name: Verify kind installation
run: kind version

- name: Run E2E tests
run: |
go mod tidy
make test-e2e



30 changes: 0 additions & 30 deletions .github/workflows/commitlint.yml

This file was deleted.

134 changes: 134 additions & 0 deletions .github/workflows/helm-chart-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: Update Helm Chart

on:
workflow_run:
workflows: ["Build & Release"]
types:
- completed
workflow_dispatch:
Comment thread
tstollin marked this conversation as resolved.

permissions:
contents: read

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
HELM_REPO: Interhyp/git-hubby-helm

jobs:
update-helm-chart:
name: Update Helm Chart
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Determine source branch
id: source
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "branch=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
echo "sha=${{ github.sha }}" >> "$GITHUB_OUTPUT"
else
echo "branch=${{ github.event.workflow_run.head_branch }}" >> "$GITHUB_OUTPUT"
echo "sha=${{ github.event.workflow_run.head_sha }}" >> "$GITHUB_OUTPUT"
fi

- name: Checkout source repository
uses: actions/checkout@v6
with:
ref: ${{ steps.source.outputs.branch }}
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod

- name: Lowercase image name
run: echo "IMAGE_NAME=${IMAGE_NAME,,}" >> "$GITHUB_ENV"

- name: Determine image version
id: version
run: |
if [[ "${{ steps.source.outputs.branch }}" == "main" ]]; then
git fetch --tags
LATEST_TAG=$(git tag --sort=-v:refname | head -1)
if [[ -n "$LATEST_TAG" ]]; then
VERSION="${LATEST_TAG#v}"
else
SHORT_SHA="$(git rev-parse --short HEAD)"
VERSION="main-${SHORT_SHA}"
fi
else
BRANCH="$(echo '${{ steps.source.outputs.branch }}' | sed 's|[^a-zA-Z0-9._-]|-|g' | cut -c1-50)"
SHORT_SHA="$(git rev-parse --short ${{ steps.source.outputs.sha }})"
VERSION="snapshot-${BRANCH}-${SHORT_SHA}"
fi
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "Image version: ${VERSION}"

- name: Checkout Helm chart repository
uses: actions/checkout@v6
with:
repository: ${{ env.HELM_REPO }}
token: ${{ secrets.HELM_CHART_PAT }}
path: helm-repo

- name: Generate Helm chart
run: make helm CHART_DIR=helm-repo/chart

- name: Update image tag in Helm chart
run: |
if [[ -f helm-repo/chart/values.yaml ]]; then
sed -i "s|tag:.*|tag: \"${{ steps.version.outputs.version }}\"|" helm-repo/chart/values.yaml
sed -i "s|repository:.*|repository: ${REGISTRY}/${IMAGE_NAME}|" helm-repo/chart/values.yaml
fi
if [[ -f helm-repo/chart/Chart.yaml ]]; then
sed -i "s|^appVersion:.*|appVersion: \"${{ steps.version.outputs.version }}\"|" helm-repo/chart/Chart.yaml
fi

- name: Determine target branch
id: branch
run: |
if [[ "${{ steps.source.outputs.branch }}" == "main" ]]; then
echo "name=update/v${{ steps.version.outputs.version }}" >> "$GITHUB_OUTPUT"
else
BRANCH="$(echo '${{ steps.source.outputs.branch }}' | sed 's|[^a-zA-Z0-9._-]|-|g' | cut -c1-50)"
echo "name=snapshot/${BRANCH}" >> "$GITHUB_OUTPUT"
fi


- name: Commit and push changes
working-directory: helm-repo
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "${{ steps.branch.outputs.name }}"
git add -A
git diff --cached --quiet && echo "No changes to commit" && exit 0
git commit -m "chore: update helm chart to version ${{ steps.version.outputs.version }}"
git push --force origin "${{ steps.branch.outputs.name }}"

- name: Create Pull Request for main branch
if: steps.source.outputs.branch == 'main'
env:
GH_TOKEN: ${{ secrets.HELM_CHART_PAT }}
run: |
cd helm-repo
EXISTING_PR=$(gh pr list --head "${{ steps.branch.outputs.name }}" --json number --jq '.[0].number' 2>/dev/null || true)
if [[ -n "$EXISTING_PR" ]]; then
echo "PR #${EXISTING_PR} already exists, updating..."
gh pr edit "$EXISTING_PR" \
--title "chore: update helm chart to v${{ steps.version.outputs.version }}" \
--body "Automated Helm chart update from [git-hubby release v${{ steps.version.outputs.version }}](https://github.com/${{ github.repository }}/releases/tag/v${{ steps.version.outputs.version }})"
else
gh pr create \
--repo "${{ env.HELM_REPO }}" \
--head "${{ steps.branch.outputs.name }}" \
--base main \
--title "chore: update helm chart to v${{ steps.version.outputs.version }}" \
--body "Automated Helm chart update from [git-hubby release v${{ steps.version.outputs.version }}](https://github.com/${{ github.repository }}/releases/tag/v${{ steps.version.outputs.version }})" \
--label "automatic-update" \
--draft
fi


27 changes: 0 additions & 27 deletions .github/workflows/lint.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,9 @@ env:
IMAGE_NAME: ${{ github.repository }}

jobs:
test:
name: Pre-Release Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod

- name: Running Tests
run: |
go mod tidy
make test

build-and-publish:
name: Build & Publish Image
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v6
Expand Down
32 changes: 0 additions & 32 deletions .github/workflows/test-e2e.yml

This file was deleted.

Loading
Loading