Skip to content

Prevent spurious deployment restarts on controller restart #44

Prevent spurious deployment restarts on controller restart

Prevent spurious deployment restarts on controller restart #44

Workflow file for this run

name: Build and Push
on:
push:
branches:
- main
- develop
tags:
- 'v*.*.*'
pull_request:
branches:
- main
- develop
env:
REGISTRY: docker.io
IMAGE_NAME: gdxbsv/traktor
jobs:
build-binary:
name: Build Binary
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Build binary
run: make build
build-docker:
name: Build Docker Image
runs-on: ubuntu-latest
needs: build-binary
permissions:
contents: read
packages: write
outputs:
image-tag: ${{ steps.meta.outputs.tags }}
image-digest: ${{ steps.build.outputs.digest }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,prefix={{branch}}-,enable=${{ github.ref_type == 'branch' }}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
VERSION=${{ github.ref_name }}
COMMIT_SHA=${{ github.sha }}
- name: Generate SBOM
if: github.event_name != 'pull_request'
uses: anchore/sbom-action@v0
with:
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}
format: spdx-json
output-file: sbom.spdx.json
- name: Upload SBOM
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: sbom
path: sbom.spdx.json
generate-manifests:
name: Generate Kubernetes Manifests
runs-on: ubuntu-latest
needs: build-docker
if: github.event_name != 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Generate install manifest
run: |
IMG=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-docker.outputs.image-digest }}
make build-installer IMG=$IMG
- name: Upload manifest
uses: actions/upload-artifact@v4
with:
name: install-manifest
path: dist/install.yaml
- name: Create Release (on tag)
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: dist/install.yaml
generate_release_notes: true
draft: false
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
security-scan:
name: Security Scan
runs-on: ubuntu-latest
needs: build-docker
if: github.event_name != 'pull_request'
permissions:
contents: read
security-events: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-docker.outputs.image-digest }}
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'
- name: Upload Trivy results to GitHub Security
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results.sarif'
- name: Run Trivy in table mode
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-docker.outputs.image-digest }}
format: 'table'
exit-code: '0'
notify:
name: Notify Build Status
runs-on: ubuntu-latest
needs: [build-binary, build-docker, generate-manifests, security-scan]
if: always() && github.event_name != 'pull_request'
steps:
- name: Check build status
run: |
if [ "${{ needs.build-binary.result }}" != "success" ] || \
[ "${{ needs.build-docker.result }}" != "success" ]; then
echo "Build failed"
exit 1
fi
echo "Build succeeded"
- name: Create success badge
if: success()
run: |
echo "✅ Build successful for ${{ github.ref_name }}"
- name: Create failure badge
if: failure()
run: |
echo "❌ Build failed for ${{ github.ref_name }}"