feat: deploy via forgejo actions

This commit is contained in:
nihonium 2025-10-08 01:10:57 +03:00
parent a5605262b3
commit b46d0e5010
Signed by untrusted user: nihonium
GPG key ID: 0251623741027CFC
4 changed files with 45 additions and 45 deletions

View file

@ -4,54 +4,42 @@ on:
push:
branches:
- master
pull_request:
jobs:
build:
runs-on: docker
container:
image: golang:1.25.0
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: docker build -t nyanimedb:latest .
- name: Save Docker image artifact
run: docker save nyanimedb:latest -o nyanimedb.tar
- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: docker-image
path: nyanimedb.tar
run: |
cd modules/server
docker build -t nyanimedb:latest .
deploy:
runs-on: docker
runs-on: self-hosted
needs: build
if: ${{ github.event.inputs.deploy == 'true' }} # manual deploy trigger
env:
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: nyanimedb
POSTGRES_PORT: 5432
POSTGRES_VERSION: 18
LOG_LEVEL: ${{ vars.LOG_LEVEL }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download image
uses: actions/download-artifact@v4
with:
name: docker-image
path: .
- name: Load Docker image
run: docker load -i nyanimedb.tar
- name: Deploy container locally
- name: Deploy containers locally
run: |
echo "Deploying nyanimedb locally..."
docker stop nyanimedb || true
docker rm nyanimedb || true
docker run -d --name nyanimedb -p 8080:8080 nyanimedb:latest
cd deploy
docker compose down || true
docker compose up -d

View file

@ -1,6 +0,0 @@
on: [push]
jobs:
test:
runs-on: docker
steps:
- run: echo All Good

View file

@ -12,19 +12,30 @@ services:
volumes:
- postgres_data:/var/lib/postgresql/data
pgadmin:
image: dpage/pgadmin4:${PGADMIN_VERSION}
container_name: pgadmin
# pgadmin:
# image: dpage/pgadmin4:${PGADMIN_VERSION}
# container_name: pgadmin
# restart: always
# environment:
# PGADMIN_DEFAULT_EMAIL: ${PGADMIN_EMAIL}
# PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_PASSWORD}
# ports:
# - "${PGADMIN_PORT}:80"
# depends_on:
# - postgres
# volumes:
# - pgadmin_data:/var/lib/pgadmin
nyanimedb:
image: nyanimedb:latest
container_name: nyanimedb
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_EMAIL}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_PASSWORD}
LOG_LEVEL: ${LOG_LEVEL}
ports:
- "${PGADMIN_PORT}:80"
- "8080:8080"
depends_on:
- postgres
volumes:
- pgadmin_data:/var/lib/pgadmin
volumes:
postgres_data:

View file

@ -0,0 +1,7 @@
FROM ubuntu:22.04
WORKDIR /app
COPY --chmod=755 nyanimedb /app
COPY templates /app/templates
EXPOSE 8080
ENTRYPOINT ["/app/nyanimedb"]