chore(go): fix lint #241
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: Go CI | |
on: | |
push: | |
branches: | |
- 'main' | |
pull_request: | |
branches: | |
- 'main' | |
jobs: | |
lint-go: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download build-essential | |
run: | | |
sudo apt update -y | |
sudo apt install -y build-essential | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
cache-dependency-path: go.sum | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v6 | |
with: | |
version: latest | |
args: --timeout 5m | |
test-go: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download build-essential | |
run: | | |
sudo apt update -y | |
sudo apt install -y build-essential | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
cache-dependency-path: go.sum | |
- name: Run tests | |
run: go test -race -covermode=atomic -timeout=30s ./... | |
build-go: | |
runs-on: ubuntu-latest | |
needs: [test-go, lint-go] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GHCR | |
if: ${{ github.ref == 'refs/heads/main' }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and export | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.ref == 'refs/heads/main' }} | |
tags: | | |
ghcr.io/darkness4/blog:latest | |
ghcr.io/darkness4/blog:dev | |
build-args: | | |
VERSION=${{ github.sha }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |