first commit

This commit is contained in:
Blake Ridgway
2026-04-11 13:58:06 -05:00
commit 04885022fd
10 changed files with 452 additions and 0 deletions

59
Makefile Normal file
View File

@@ -0,0 +1,59 @@
BINARY = gitea-pr-reviewer
SERVICE = prbot
CMD = ./cmd/reviewer
.PHONY: build
build:
go build -o $(BINARY) $(CMD)
.PHONY: run
run:
go run $(CMD)
.PHONY: run-env
run-env:
@test -f .env || (echo "No .env file found. Copy .env.example and fill it in." && exit 1)
env $$(grep '^[A-Z]' .env | xargs) go run $(CMD)
.PHONY: cross
cross:
GOOS=openbsd GOARCH=amd64 go build -ldflags="-s -w" -o $(BINARY)-openbsd-amd64 $(CMD)
.PHONY: tidy
tidy:
go mod tidy
.PHONY: vet
vet:
go vet ./...
.PHONY: clean
clean:
rm -f $(BINARY) $(BINARY)-openbsd-amd64
DEPLOY_HOST ?= srv01
.PHONY: deploy
deploy: cross
scp $(BINARY)-openbsd-amd64 $(DEPLOY_HOST):/usr/local/bin/$(BINARY)
ssh $(DEPLOY_HOST) "rcctl restart $(SERVICE)"
# First-time server setup. Run once after provisioning.
# Requires the wrapper script to already exist at /usr/local/bin/gitea-pr-reviewer-run.
.PHONY: setup-server
setup-server:
ssh $(DEPLOY_HOST) "useradd -s /sbin/nologin -d /var/empty _prbot 2>/dev/null || true"
scp scripts/rc.d.prbot $(DEPLOY_HOST):/etc/rc.d/$(SERVICE)
ssh $(DEPLOY_HOST) "chmod 555 /etc/rc.d/$(SERVICE) && rcctl enable $(SERVICE)"
.PHONY: help
help:
@echo "Targets:"
@echo " build Build binary for current OS"
@echo " run Run without .env"
@echo " run-env Run with .env file"
@echo " cross Cross-compile for OpenBSD amd64"
@echo " tidy go mod tidy"
@echo " vet go vet"
@echo " deploy Cross-compile and deploy to OpenBSD server"
@echo " clean Remove build artifacts"