mirror of
https://github.com/YuzuZensai/TrollSSH.git
synced 2026-09-13 15:49:02 +00:00
90 lines
2.6 KiB
YAML
90 lines
2.6 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: ["**"]
|
|
tags: ["v*"]
|
|
pull_request:
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: Format check
|
|
run: test -z "$(gofmt -l src)"
|
|
|
|
- name: Vet
|
|
run: go vet ./src/
|
|
|
|
- name: Staticcheck
|
|
uses: dominikh/staticcheck-action@v1
|
|
with:
|
|
install-go: false
|
|
|
|
- name: golangci-lint
|
|
uses: golangci/golangci-lint-action@v7
|
|
with:
|
|
working-directory: src
|
|
|
|
- name: Build
|
|
run: go build -o trollssh ./src
|
|
|
|
- name: Unit tests
|
|
run: go test -race ./src/
|
|
|
|
docker:
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Determine push conditions
|
|
id: should_push
|
|
run: |
|
|
if [[ "${{ github.event_name }}" == "push" && ( "${{ github.ref }}" == "refs/heads/main" || "${{ github.ref }}" == refs/tags/v* ) ]]; then
|
|
echo "push=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "push=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Docker metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ghcr.io/yuzuzensai/trollssh
|
|
tags: |
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
type=semver,pattern=v{{version}}
|
|
type=sha,prefix=sha-,format=short
|
|
|
|
- name: Log in to GHCR
|
|
if: steps.should_push.outputs.push == 'true'
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build (and push) image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: ${{ steps.should_push.outputs.push == 'true' }}
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
provenance: false
|