github.com/martinohmann/rfoutlet@v1.2.1-0.20220707195255-8a66aa411105/.github/workflows/build.yml (about) 1 --- 2 name: build 3 on: 4 push: 5 branches: 6 - 'master' 7 tags: 8 - 'v*' 9 pull_request: 10 jobs: 11 build: 12 strategy: 13 matrix: 14 go-version: [1.13.x, 1.15.x, 1.16.x] 15 runs-on: ubuntu-latest 16 steps: 17 - name: Checkout 18 uses: actions/checkout@v3 19 with: 20 fetch-depth: 0 21 - name: Setup 22 uses: actions/setup-go@v2 23 with: 24 go-version: ${{ matrix.go-version }} 25 - name: Cache go modules 26 uses: actions/cache@v3.0.4 27 with: 28 path: ~/go/pkg/mod 29 key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} 30 restore-keys: ${{ runner.os }}-go-${{ matrix.go-version }}- 31 - name: Download go modules 32 run: go mod download 33 - name: Run go test 34 run: make coverage 35 - name: Run go vet 36 run: go vet ./... 37 - name: Install golangci-lint 38 run: | 39 curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \ 40 sh -s -- -b $(go env GOPATH)/bin v1.31.0 41 - name: Run golangci-lint 42 run: golangci-lint run 43 - name: Upload coverage 44 uses: codecov/codecov-action@v2.1.0 45 if: matrix.go-version == '1.15.x' 46 with: 47 token: ${{ secrets.CODECOV_TOKEN }} 48 file: ./coverage.txt 49 - name: GoReleaser 50 uses: goreleaser/goreleaser-action@v2 51 if: matrix.go-version == '1.15.x' && startsWith(github.ref, 'refs/tags/') 52 with: 53 version: latest 54 args: release --rm-dist 55 env: 56 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 57 build-web: 58 defaults: 59 run: 60 working-directory: web 61 strategy: 62 matrix: 63 node-version: ['15', '16'] 64 runs-on: ubuntu-latest 65 steps: 66 - name: Checkout 67 uses: actions/checkout@v3 68 - name: Setup 69 uses: actions/setup-node@v3 70 with: 71 node-version: ${{ matrix.go-version }} 72 - name: Cache node modules 73 uses: actions/cache@v3.0.4 74 with: 75 path: ~/.npm 76 key: ${{ runner.os }}-npm-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }} 77 restore-keys: ${{ runner.os }}-npm-${{ matrix.go-version }}- 78 - name: Install node modules 79 run: npm install 80 - name: Build app 81 run: npm run build 82 docker-build: 83 runs-on: ubuntu-latest 84 steps: 85 - name: Checkout 86 uses: actions/checkout@v3 87 - name: Docker meta 88 id: docker_meta 89 uses: crazy-max/ghaction-docker-meta@v4.0.1 90 with: 91 images: mohmann/rfoutlet 92 - name: Set up QEMU 93 uses: docker/setup-qemu-action@v1 94 - name: Set up Docker Buildx 95 uses: docker/setup-buildx-action@v1 96 - name: Cache Docker layers 97 uses: actions/cache@v3.0.4 98 with: 99 path: /tmp/.buildx-cache 100 key: ${{ runner.os }}-buildx-${{ github.sha }} 101 restore-keys: | 102 ${{ runner.os }}-buildx- 103 - name: Login to DockerHub 104 uses: docker/login-action@v1 105 if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master' 106 with: 107 username: ${{ secrets.DOCKERHUB_USERNAME }} 108 password: ${{ secrets.DOCKERHUB_TOKEN }} 109 - name: Build 110 uses: docker/build-push-action@v3 111 with: 112 cache-from: | 113 type=registry,ref=mohmann/rfoutlet:latest 114 type=local,src=/tmp/.buildx-cache 115 cache-to: type=local,dest=/tmp/.buildx-cache 116 context: . 117 file: ./Dockerfile 118 platforms: linux/amd64,linux/arm/v7 119 push: ${{ startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master' }} 120 tags: ${{ steps.docker_meta.outputs.tags }} 121 labels: ${{ steps.docker_meta.outputs.labels }}