adds forgejo workflow
This commit is contained in:
parent
de4be50192
commit
09c3a051dd
1 changed files with 52 additions and 0 deletions
52
.forgejo/workflows/deploy.yml
Normal file
52
.forgejo/workflows/deploy.yml
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
name: Build, Push and Deploy
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["main"]
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: forgejo.git.pb1497.com
|
||||||
|
IMAGE_NAME: pb/skyjo-be
|
||||||
|
# Wir nutzen hier den internen Namen des DinD Containers für Docker-Befehle
|
||||||
|
DOCKER_HOST: tcp://docker-in-docker:2375
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Login to Forgejo Registry
|
||||||
|
uses: actions/docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
# Erstelle ein "App-Passwort" in Forgejo unter Einstellungen -> Anwendungen
|
||||||
|
password: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and Push Image
|
||||||
|
uses: actions/docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
needs: build-and-push
|
||||||
|
runs-on: host
|
||||||
|
steps:
|
||||||
|
- name: Deploy Container
|
||||||
|
run: |
|
||||||
|
# Einloggen auf dem Host-Runner (falls nötig)
|
||||||
|
docker login ${{ env.REGISTRY }} -u ${{ github.actor }} -p ${{ secrets.FORGEJO_TOKEN }}
|
||||||
|
|
||||||
|
# Altes Image ziehen und Container neu starten
|
||||||
|
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||||
|
|
||||||
|
# Falls du ein docker-compose.yml im Repo hast:
|
||||||
|
# docker compose up -d --force-recreate
|
||||||
|
|
||||||
|
# Oder einfacher Docker-Run (Beispiel):
|
||||||
|
docker stop skyjo-be || true
|
||||||
|
docker rm skyjo-be || true
|
||||||
|
docker run -d --name skyjo-be ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||||
Loading…
Reference in a new issue