name: CI on: push: branches: - main pull_request: jobs: lint: name: Lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5 with: go-version: '1.21' cache: true - name: Cache golangci-lint uses: actions/cache@v3 with: path: .cache/golangci-lint key: ${{ runner.os }}-golangci-lint-${{ hashFiles('**/*.go') }} restore-keys: | ${{ runner.os }}-golangci-lint- - name: Run golangci-lint uses: golangci/golangci-lint-action@v3 with: version: latest args: --timeout=5m only-new-issues: true skip-cache: true # Using our own cache test: name: Test runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5 with: go-version: '1.21' cache: true - name: Run tests run: go test -v ./... build: name: Build runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5 with: go-version: '1.21' - name: Build and test run: | go mod download go build ./... go test ./... - name: Login to Container Registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Extract metadata id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build and push portal image uses: docker/build-push-action@v5 with: context: . file: build/portal/Dockerfile push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }}-portal labels: ${{ steps.meta.outputs.labels }} - name: Build and push operator image uses: docker/build-push-action@v5 with: context: . file: build/operator/Dockerfile push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }}-operator labels: ${{ steps.meta.outputs.labels }} # Optional: Add Docker build step if needed docker: name: Docker Build runs-on: ubuntu-latest needs: [lint, test, build] if: github.ref == 'refs/heads/main' # Only run on main branch steps: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build Docker image uses: docker/build-push-action@v5 with: context: . push: false # Set to true if you want to push to a registry tags: container-mom:latest