Add revive as linter #373
Workflow file for this run
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: | |
tags: | |
- v* | |
branches: | |
- main | |
pull_request: | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
# true when a push on the main branch | |
PUSH_ARTIFACT: | | |
${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'pull_request' }} | |
jobs: | |
linter: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Lint Dockerfile | |
uses: hadolint/hadolint-action@master | |
with: | |
dockerfile: "Dockerfile" | |
mod-tidy: | |
name: mod-tidy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: set up go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.22.1 | |
id: go | |
- name: go mod tidy | |
run: go mod tidy | |
- run: | | |
if ! git diff --exit-code -- go.mod go.sum; then | |
echo "Modules not tidy; please run 'go mod tidy'" | |
exit 1 | |
fi; | |
build: | |
name: build | |
runs-on: ubuntu-latest | |
needs: [mod-tidy] | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: set up go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.22.1 | |
id: go | |
- run: go version | |
- name: Promu | |
run: make promu | |
- name: Build | |
run: make build | |
container: | |
runs-on: ubuntu-latest | |
needs: [mod-tidy, build] | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- uses: docker/setup-buildx-action@v3.8.0 | |
with: | |
install: true | |
- uses: docker/login-action@v3.3.0 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: docker/metadata-action@v5.6.1 | |
id: metadata | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=sha,prefix=sha-,format=long | |
type=ref,event=pr | |
type=ref,event=tag | |
type=semver,pattern={{version}} | |
- uses: docker/build-push-action@v6.10.0 | |
with: | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
push: ${{ env.PUSH_ARTIFACT }} | |
tags: ${{ steps.metadata.outputs.tags }} | |
labels: ${{ steps.metadata.outputs.labels }} |