Lint as separate step #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI Workflow | |
on: | |
pull_request: | |
paths: | |
- '**' | |
push: | |
branches: | |
- main | |
paths: | |
- '**' | |
jobs: | |
lint-and-test: | |
name: Lint and test code and charts | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.23' | |
cache: true | |
cache-dependency-path: go.sum | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v6 | |
with: | |
version: v1.60 | |
- name: Run tests | |
run: | | |
make test | |
make integration-test | |
- name: Install Helm | |
uses: azure/setup-helm@v4 | |
- name: Lint Helm charts | |
run: | | |
helm lint kubenetmon/deploy/helm | |
- name: Test Helm charts | |
run: | | |
helm template kubenetmon/deploy/helm | kubectl apply --dry-run=client -f - | |
build-and-publish: | |
name: Build and Publish Docker and Helm Chart | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
needs: lint-and-test | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.23' | |
- name: Build Docker image | |
run: | | |
docker build -t your-docker-repo/kubenetmon:${{ github.sha }} . | |
- name: Push Docker image | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ secrets.GITHUB_ACTOR }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- run: | | |
docker push your-docker-repo/kubenetmon:${{ github.sha }} | |
- name: Package Helm chart | |
run: | | |
helm package kubenetmon/deploy/helm | |
- name: Publish Helm chart | |
uses: helm/[email protected] | |
with: | |
charts_dir: kubenetmon/deploy/helm | |
release_repo: your-helm-repo-url |