nyanimedb/.forgejo/workflows/build-and-deploy.yml

42 lines
977 B
YAML

name: Build and Deploy Go App
on:
push:
branches:
- master
workflow_dispatch:
do_deploy:
description: 'Deploy dev version'
required: true
type: boolean
default: false
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.do_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