sillygod/cdp-cache

View on GitHub
.github/workflows/main.yml

Summary

Maintainability
Test Coverage
name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  push:
    branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    name: Build
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      - name: set up go 1.x
        uses: actions/setup-go@v2
        with:
          go-version: '1.20'
        id: go

      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - name: checkt out
        uses: actions/checkout@v2

      # Runs test
      - name: run test
        run: |
          go test -v ./...

      # Generate test coverage for code climate
      - name: generate test coverage
        uses: paambaati/codeclimate-action@v2.6.0
        env:
          CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTED_ID }}
        with:
          debug: true
          prefix: github.com/sillygod/cdp-cache # this is important
          coverageCommand: go test -coverprofile=c.out ./...
          coverageLocations: ${{ github.workspace }}/c.out:gocov

      - name: build
        run: |
          CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o caddy cmd/main.go
          zip binarys caddy

      - name: upload assets
        uses: actions/upload-artifact@v1
        with:
          name: binary
          path: ./binarys.zip

      - name: docker build and push
        uses: docker/build-push-action@v1
        with:
          dockerfile: build/ci.dockerfile
          registry: docker.pkg.github.com
          repository: sillygod/cdp-cache/caddy
          username: sillygod
          password: ${{ secrets.GITHUB_TOKEN }}
          tags: latest