feat: add CI workflow for testing and building ha-gateway and discord-bot
Some checks failed
CI / test (push) Failing after 9s
CI / build-ha-gateway (push) Has been skipped
CI / build-discord-bot (push) Has been skipped

This commit is contained in:
Nik Afiq 2026-04-06 20:29:37 +09:00
parent 94ab7ea42b
commit 97f9f5350e

88
.gitea/workflows/ci.yaml Normal file
View File

@ -0,0 +1,88 @@
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
REGISTRY: gitea.nik4nao.com
IMAGE_PREFIX: gitea.nik4nao.com/nik
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version-file: go.work
cache-dependency-path: |
go.work.sum
ha-gateway/go.sum
discord-bot/go.sum
gen/go.sum
- name: go vet
run: |
cd gen && go vet ./...
cd ../ha-gateway && go vet ./...
cd ../discord-bot && go vet ./...
- name: go test
run: |
cd gen && go test ./...
cd ../ha-gateway && go test ./...
cd ../discord-bot && go test ./...
build-ha-gateway:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- uses: docker/build-push-action@v7
with:
context: .
file: ha-gateway/Dockerfile
push: true
platforms: linux/amd64
tags: |
${{ env.IMAGE_PREFIX }}/ha-gateway:${{ github.sha }}
${{ env.IMAGE_PREFIX }}/ha-gateway:latest
build-discord-bot:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- uses: docker/build-push-action@v7
with:
context: .
file: discord-bot/Dockerfile
push: true
platforms: linux/amd64
tags: |
${{ env.IMAGE_PREFIX }}/discord-bot:${{ github.sha }}
${{ env.IMAGE_PREFIX }}/discord-bot:latest