From 97f9f5350eaf8ebe8fbc23e0ed673a95fa422408 Mon Sep 17 00:00:00 2001 From: Nik Afiq Date: Mon, 6 Apr 2026 20:29:37 +0900 Subject: [PATCH] feat: add CI workflow for testing and building ha-gateway and discord-bot --- .gitea/workflows/ci.yaml | 88 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .gitea/workflows/ci.yaml diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..8031eca --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -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