forked from nihonium/nyanimedb
feat: deploy pipeline
This commit is contained in:
parent
fbfc6d25fa
commit
21e19fbc36
1 changed files with 57 additions and 0 deletions
57
.forgejo/workflows/build-and-deploy.yml
Normal file
57
.forgejo/workflows/build-and-deploy.yml
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
name: Build and Deploy Go App
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: golang:1.25.0
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build Go app
|
||||
run: |
|
||||
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
|
||||
|
||||
deploy:
|
||||
runs-on: docker
|
||||
needs: build
|
||||
if: ${{ github.event.inputs.deploy == 'true' }} # manual deploy trigger
|
||||
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
|
||||
run: |
|
||||
echo "Deploying nyanimedb locally..."
|
||||
docker stop nyanimedb || true
|
||||
docker rm nyanimedb || true
|
||||
docker run -d --name nyanimedb -p 8080:8080 nyanimedb:latest
|
||||
Loading…
Add table
Add a link
Reference in a new issue