feat: deploy via forgejo actions
This commit is contained in:
parent
a5605262b3
commit
b46d0e5010
4 changed files with 45 additions and 45 deletions
|
|
@ -4,54 +4,42 @@ on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: docker
|
runs-on: self-hosted
|
||||||
container:
|
|
||||||
image: golang:1.25.0
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Build Go app
|
- name: Build Go app
|
||||||
run: |
|
run: |
|
||||||
|
cd modules/server
|
||||||
go mod tidy
|
go mod tidy
|
||||||
go build -o nyanimedb .
|
go build -o nyanimedb .
|
||||||
|
|
||||||
- name: Build Docker image
|
- name: Build Docker image
|
||||||
run: docker build -t nyanimedb:latest .
|
run: |
|
||||||
|
cd modules/server
|
||||||
- name: Save Docker image artifact
|
docker build -t nyanimedb:latest .
|
||||||
run: docker save nyanimedb:latest -o nyanimedb.tar
|
|
||||||
|
|
||||||
- name: Upload image artifact
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: docker-image
|
|
||||||
path: nyanimedb.tar
|
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: docker
|
runs-on: self-hosted
|
||||||
needs: build
|
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:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Download image
|
- name: Deploy containers locally
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
name: docker-image
|
|
||||||
path: .
|
|
||||||
|
|
||||||
- name: Load Docker image
|
|
||||||
run: docker load -i nyanimedb.tar
|
|
||||||
|
|
||||||
- name: Deploy container locally
|
|
||||||
run: |
|
run: |
|
||||||
echo "Deploying nyanimedb locally..."
|
cd deploy
|
||||||
docker stop nyanimedb || true
|
docker compose down || true
|
||||||
docker rm nyanimedb || true
|
docker compose up -d
|
||||||
docker run -d --name nyanimedb -p 8080:8080 nyanimedb:latest
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
on: [push]
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
runs-on: docker
|
|
||||||
steps:
|
|
||||||
- run: echo All Good
|
|
||||||
|
|
@ -12,19 +12,30 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- postgres_data:/var/lib/postgresql/data
|
- postgres_data:/var/lib/postgresql/data
|
||||||
|
|
||||||
pgadmin:
|
# pgadmin:
|
||||||
image: dpage/pgadmin4:${PGADMIN_VERSION}
|
# image: dpage/pgadmin4:${PGADMIN_VERSION}
|
||||||
container_name: pgadmin
|
# 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
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_EMAIL}
|
LOG_LEVEL: ${LOG_LEVEL}
|
||||||
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_PASSWORD}
|
|
||||||
ports:
|
ports:
|
||||||
- "${PGADMIN_PORT}:80"
|
- "8080:8080"
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
volumes:
|
|
||||||
- pgadmin_data:/var/lib/pgadmin
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
|
|
|
||||||
7
modules/server/Dockerfile
Normal file
7
modules/server/Dockerfile
Normal 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"]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue