Add Gitea deploy workflow
Deploy / deploy (push) Has been cancelled

This commit is contained in:
2026-06-07 18:56:42 +09:00
parent 6f9cc0bbbb
commit 2951c7ae17
2 changed files with 64 additions and 3 deletions
+62
View File
@@ -0,0 +1,62 @@
name: Deploy
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy to Oracle VM
env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
DEPLOY_REPO: ${{ secrets.DEPLOY_REPO }}
run: |
set -eu
apt-get update
apt-get install -y --no-install-recommends openssh-client ca-certificates
DEPLOY_PORT="${DEPLOY_PORT:-22}"
DEPLOY_PATH="${DEPLOY_PATH:-/home/ubuntu/low-level-guy.com}"
DEPLOY_REPO="${DEPLOY_REPO:-https://git.low-level-guy.com/josufh/low-level-guy.com.git}"
mkdir -p ~/.ssh
chmod 700 ~/.ssh
printf '%s\n' "$DEPLOY_SSH_KEY" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
ssh-keyscan -p "$DEPLOY_PORT" "$DEPLOY_HOST" >> ~/.ssh/known_hosts
ssh -i ~/.ssh/deploy_key -p "$DEPLOY_PORT" "$DEPLOY_USER@$DEPLOY_HOST" << EOF
set -eu
if [ ! -d "$DEPLOY_PATH/.git" ]; then
rm -rf "$DEPLOY_PATH"
mkdir -p "$DEPLOY_PATH"
git clone "$DEPLOY_REPO" "$DEPLOY_PATH"
fi
cd "$DEPLOY_PATH"
git fetch origin main
git reset --hard origin/main
docker build -t lowlevelguycom:latest .
docker stop low-level-guy-com || true
docker rm low-level-guy-com || true
docker run -d \
--name low-level-guy-com \
--restart unless-stopped \
-p 5000:5000 \
lowlevelguycom:latest
EOF
+2 -3
View File
@@ -9,11 +9,10 @@ RUN dotnet publish -c Release -o /app/publish --no-restore
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
ENV ASPNETCORE_URLS=http://0.0.0.0:8080
ENV ASPNETCORE_URLS=http://0.0.0.0:5000
WORKDIR /app
COPY --from=build /app/publish /app
EXPOSE 80
EXPOSE 5000
ENTRYPOINT ["dotnet", "LowLevelGuyCom.dll"]