Add CI workflow for Docker build and deployment; update Dockerfile and adjust health reduction logic in PetActionService; modify database connection string in appsettings.json
This commit is contained in:
parent
b84599b370
commit
1cf5f07c80
63
.gitea/workflows/main.yml
Normal file
63
.gitea/workflows/main.yml
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
name: Main Build & Deploy
|
||||||
|
|
||||||
|
on: workflow_dispatch
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build and Push Docker Image (amd64 and arm64)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install docker and docker compose
|
||||||
|
run: |
|
||||||
|
apt update
|
||||||
|
apt install -y docker docker-compose
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
id: buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
config-inline: |
|
||||||
|
[registry."git.ivanch.me"]
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: https://github.com/docker/login-action@v3.3.0
|
||||||
|
with:
|
||||||
|
registry: git.ivanch.me
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build Docker image and push
|
||||||
|
id: docker_build
|
||||||
|
uses: https://github.com/docker/build-push-action@v6.12.0
|
||||||
|
with:
|
||||||
|
context: ./
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: git.ivanch.me/ivanch/pet-companion/pet-companion-api:latest
|
||||||
|
platforms: linux/amd64, linux/arm64
|
||||||
|
|
||||||
|
- name: Image digest
|
||||||
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||||
|
|
||||||
|
deploy_live:
|
||||||
|
name: Deploy Live
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Recreate container
|
||||||
|
uses: https://github.com/appleboy/ssh-action@v1.2.0
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.LIVE_HOST }}
|
||||||
|
username: ${{ secrets.LIVE_USERNAME }}
|
||||||
|
key: ${{ secrets.LIVE_KEY }}
|
||||||
|
port: ${{ secrets.LIVE_PORT }}
|
||||||
|
script: |
|
||||||
|
cd ${{ secrets.LIVE_PROJECT_DIR }}
|
||||||
|
docker compose down
|
||||||
|
docker compose rm
|
||||||
|
docker compose pull
|
||||||
|
docker compose up -d
|
@ -1,6 +1,3 @@
|
|||||||
# See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
|
||||||
|
|
||||||
# This stage is used when running from VS in fast mode (Default for Debug configuration)
|
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||||
USER app
|
USER app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
@ -108,7 +108,7 @@ namespace PetCompanion.Services
|
|||||||
pet.Health -= 5;
|
pet.Health -= 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (random.Next(0, 100) < 5)
|
if (random.Next(0, 100) < 2)
|
||||||
{
|
{
|
||||||
gathered.Add(new ActionGathered
|
gathered.Add(new ActionGathered
|
||||||
{
|
{
|
||||||
@ -125,7 +125,7 @@ namespace PetCompanion.Services
|
|||||||
Amount = (int)(baseRate * (pet.Stats.Strength * 0.25))
|
Amount = (int)(baseRate * (pet.Stats.Strength * 0.25))
|
||||||
});
|
});
|
||||||
|
|
||||||
if (random.Next(0, 100) < 10)
|
if (random.Next(0, 100) < 5)
|
||||||
{
|
{
|
||||||
pet.Health -= random.Next(5, 10);
|
pet.Health -= random.Next(5, 10);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"DefaultConnection": "Data Source=petcompanion.db"
|
"DefaultConnection": "Data Source=game-data/petcompanion.db"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user