37 lines
842 B
YAML
37 lines
842 B
YAML
name: Build and Deploy Go App
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: self-hosted
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Build Go app
|
|
run: |
|
|
cd modules/server
|
|
go mod tidy
|
|
go build -o nyanimedb .
|
|
|
|
- name: Build Docker image
|
|
run: |
|
|
cd modules/server
|
|
docker build -t nyanimedb:latest .
|
|
|
|
deploy:
|
|
runs-on: self-hosted
|
|
needs: build
|
|
if: ${{ github.event.inputs.deploy == 'true' }} # manual deploy trigger
|
|
steps:
|
|
- name: Deploy container locally
|
|
run: |
|
|
echo "Deploying nyanimedb locally..."
|
|
docker stop nyanimedb || true
|
|
docker rm nyanimedb || true
|
|
docker run -d --name nyanimedb -p 8080:8080 nyanimedb:latest
|