69 lines
2.1 KiB
YAML
69 lines
2.1 KiB
YAML
#
|
|
# .gitea/gitea-ci.yaml
|
|
#
|
|
|
|
name: Build And Test
|
|
run-name: ${{ gitea.actor }} started ci pipeline
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- 'v*' # Tags, die mit "v" anfangen, z. B. v1.0.0
|
|
workflow_dispatch:
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: https://github.com/actions/checkout@v6
|
|
- name: Use Go
|
|
uses: https://github.com/actions/setup-go@v6
|
|
with:
|
|
go-version: '1.24'
|
|
- run: go version
|
|
- run: ls -lha
|
|
- run: go build -v ./...
|
|
|
|
publish:
|
|
needs: build
|
|
name: Build and Publish Docker Image
|
|
runs-on: ubuntu-latest
|
|
if: gitea.ref == 'refs/heads/main'
|
|
steps:
|
|
- uses: https://github.com/actions/checkout@v6
|
|
|
|
- name: Docker login to Docker Hub
|
|
run: |
|
|
echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login docker.io \
|
|
--username "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
|
|
- name: Docker login to Gitea Registry
|
|
run: |
|
|
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login git.hnrx.net \
|
|
--username "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
|
|
|
- name: Setup Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
with:
|
|
buildkitd-config-inline: |
|
|
[registry."docker.io"]
|
|
username = "${{ secrets.DOCKERHUB_USERNAME }}"
|
|
password = "${{ secrets.DOCKERHUB_TOKEN }}"
|
|
[registry."git.hnrx.net"]
|
|
username = "${{ secrets.DOCKER_USERNAME }}"
|
|
password = "${{ secrets.DOCKER_PASSWORD }}"
|
|
- name: Build and Push Docker latest Image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: git.hnrx.net/hnrx/manage-servers:latest
|
|
file: ./Dockerfile
|
|
|
|
- name: Build and Push Docker versioned Image ${{ gitea.ref_name }}
|
|
if: startsWith(gitea.ref, 'refs/tags/v') && (gitea.ref_name =~ '^v[0-9]+\.[0-9]+\.[0-9]+$')
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: git.hnrx.net/hnrx/manage-servers:${{ gitea.ref_name }}
|
|
file: ./Dockerfile |