Update actions/setup-go action to v5 #92
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- '!*' | |
pull_request: | |
branches: | |
- '*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
name: build | |
steps: | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.18 | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Configure cache paths | |
id: go-cache-paths | |
run: | | |
echo "::set-output name=go-build::$(go env GOCACHE)" | |
echo "::set-output name=go-mod::$(go env GOMODCACHE)" | |
echo "::set-output name=envtest::internal/testdata/$(go env GOOS)" | |
- name: Restore Go build cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.go-cache-paths.outputs.go-build }} | |
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} | |
- name: Restore Go mod cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.go-cache-paths.outputs.go-mod }} | |
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} | |
- name: Restore envtest deps cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.go-cache-paths.outputs.envtest }} | |
key: ${{ runner.os }}-envtest-${{ hashFiles('**/internal/testdata/get-binaries.sh') }} | |
- name: Download deps | |
run: go mod download | |
- name: Download envtest deps | |
run: (cd internal/testdata && ./get-binaries.sh) | |
- name: Test controller | |
run: go test ./internal/... | |
- name: Build controller | |
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o controller ./cmd/main.go | |
- name: Build Docker image | |
run: docker build . -t slamdev/cortex-rule-watcher | |
- name: Login to Dockerhub | |
if: github.ref == 'refs/heads/main' | |
run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u slamdev --password-stdin | |
- name: Push Docker image | |
if: github.ref == 'refs/heads/main' | |
run: docker push slamdev/cortex-rule-watcher:latest |