60 lines
1.4 KiB
YAML
60 lines
1.4 KiB
YAML
name: CI/CD
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: linux-amd64
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.25.6'
|
|
|
|
- name: Download dependencies
|
|
working-directory: ./backend
|
|
run: go mod download
|
|
|
|
- name: Build
|
|
working-directory: ./backend
|
|
run: go build -v ./...
|
|
|
|
- name: Test
|
|
working-directory: ./backend
|
|
run: go test -v ./...
|
|
|
|
build-and-push:
|
|
runs-on: linux-amd64
|
|
needs: test
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Login to Gitea Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: gitea.home.hrajfrisbee.cz
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ./backend
|
|
file: ./backend/Dockerfile.prod
|
|
push: true
|
|
tags: |
|
|
gitea.home.hrajfrisbee.cz/${{ github.repository }}/backend:latest
|
|
gitea.home.hrajfrisbee.cz/${{ github.repository }}/backend:${{ github.sha }}
|