93 lines
No EOL
2.7 KiB
YAML
93 lines
No EOL
2.7 KiB
YAML
name: ci
|
|
|
|
on: push
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-22.04
|
|
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: '1.24'
|
|
cache: true
|
|
cache-dependency-path: go.sum
|
|
|
|
- name: Validate Go Modules
|
|
run: |
|
|
go mod tidy
|
|
git diff --exit-code go.sum || echo "go.sum was updated; please commit changes"
|
|
go mod download
|
|
|
|
- name: Run Unit Tests
|
|
run: go test ./... -v
|
|
|
|
- name: Repository meta
|
|
id: repository
|
|
run: |
|
|
registry=${{ github.server_url }}
|
|
registry=${registry##http*://}
|
|
echo "registry=${registry}" >> "$GITHUB_OUTPUT"
|
|
echo "registry=${registry}"
|
|
repository="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')"
|
|
echo "repository=${repository}" >> "$GITHUB_OUTPUT"
|
|
echo "repository=${repository}"
|
|
|
|
- name: Docker meta
|
|
uses: docker/metadata-action@v5
|
|
id: docker
|
|
with:
|
|
images: ${{ steps.repository.outputs.registry }}/${{ steps.repository.outputs.repository }}
|
|
tags: |
|
|
# Für push-Events: Tag 'latest'
|
|
type=raw,value=latest,enable=${{ github.event_name == 'push' }}
|
|
# Für tag-Events: Nutze den Git-Tag (z. B. v1.0.0)
|
|
type=ref,event=tag
|
|
# Optional: Commit-SHA für alle Events
|
|
type=sha,prefix=sha-
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
with:
|
|
buildkitd-flags: '--allow-insecure-entitlement network.host'
|
|
driver-opts: network=host
|
|
|
|
- name: Build Docker Image
|
|
uses: docker/build-push-action@v6
|
|
id: build
|
|
with:
|
|
context: .
|
|
push: false
|
|
allow: network.host
|
|
network: host
|
|
platforms: linux/amd64,linux/arm64
|
|
tags: ${{ steps.docker.outputs.tags }}
|
|
outputs: type=docker
|
|
no-cache: false
|
|
|
|
- name: Run Tests in Docker Image
|
|
run: |
|
|
docker run --rm \
|
|
-v $(pwd):/app \
|
|
-w /app \
|
|
${{ steps.docker.outputs.tags | split('\n') | first }} \
|
|
go test ./... -v
|
|
|
|
- name: Login to registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ steps.repository.outputs.registry }}
|
|
username: ${{ secrets.PACKAGES_USER }}
|
|
password: ${{ secrets.PACKAGES_TOKEN }}
|
|
|
|
- name: Push Docker Image
|
|
run: |
|
|
docker push ${{ steps.docker.outputs.tags | split('\n') | first }}
|
|
|