Nik Afiq 066224715a
Some checks failed
CI / test (push) Successful in 26s
CI / build-ha-gateway (push) Failing after 2m28s
CI / build-discord-bot (push) Failing after 7s
feat: add environment variables for Go caching in CI workflow
2026-04-06 20:37:50 +09:00

96 lines
2.3 KiB
YAML

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
env:
REGISTRY: gitea.nik4nao.com
IMAGE_PREFIX: gitea.nik4nao.com/nik
GOPATH: /tmp/go
GOMODCACHE: /tmp/go/pkg/mod
GOCACHE: /tmp/go-build
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: prepare go cache dirs
run: mkdir -p "$GOMODCACHE" "$GOCACHE"
- 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