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: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build and push 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 # Add registry credentials if pushing to a registry: # registry: your-registry # username: ${{ secrets.REGISTRY_USERNAME }} # password: ${{ secrets.REGISTRY_PASSWORD }} # 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