Skip to content

CI

CI #80

Workflow file for this run

name: CI
on:
workflow_dispatch:
permissions:
contents: read
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v6
with:
repository: nasty-project/nasty-go
token: ${{ secrets.NASTY_PAT }}
path: nasty-go
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: latest
args: --config .golangci.yml
test:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v6
with:
repository: nasty-project/nasty-go
token: ${{ secrets.NASTY_PAT }}
path: nasty-go
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Download dependencies
run: go mod download
- name: Run tests
run: make test-unit
- name: Build
run: make build
build-and-push:
name: Build and Push Image
runs-on: ubuntu-latest
needs: [lint, test]
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v6
with:
repository: nasty-project/nasty-go
token: ${{ secrets.NASTY_PAT }}
path: nasty-go
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get version info
id: version
run: |
VERSION="0.0.1"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "commit=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_OUTPUT
- name: Build and push images
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
push: true
build-args: |
VERSION=${{ steps.version.outputs.version }}
GIT_COMMIT=${{ steps.version.outputs.commit }}
BUILD_DATE=${{ steps.version.outputs.date }}
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/nasty-csi:latest
ghcr.io/${{ github.repository }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max