feat: add CI workflow for testing and building ha-gateway and discord-bot
This commit is contained in:
parent
94ab7ea42b
commit
97f9f5350e
88
.gitea/workflows/ci.yaml
Normal file
88
.gitea/workflows/ci.yaml
Normal 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
|
||||||
Loading…
x
Reference in New Issue
Block a user