58 lines
1.6 KiB
YAML
58 lines
1.6 KiB
YAML
name: Build & Deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
env:
|
|
IMAGE: ${{ vars.REGISTRY_URL }}/${{ github.repository_owner }}/slaapkampioen
|
|
|
|
jobs:
|
|
# ── 1. Bouw de Docker image en push naar Gitea registry ──
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Log in to Gitea registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ vars.REGISTRY_URL }}
|
|
username: ${{ vars.REGISTRY_USER }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Build & push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
${{ env.IMAGE }}:latest
|
|
${{ env.IMAGE }}:${{ github.sha }}
|
|
|
|
# # ── 2. Deployen op de server via SSH ──
|
|
# deploy:
|
|
# needs: build
|
|
# runs-on: ubuntu-latest
|
|
# steps:
|
|
# - name: Deploy via SSH
|
|
# uses: appleboy/ssh-action@master
|
|
# with:
|
|
# host: ${{ vars.DEPLOY_HOST }}
|
|
# username: ${{ vars.DEPLOY_USER }}
|
|
# key: ${{ secrets.DEPLOY_KEY }}
|
|
# script: |
|
|
# # Inloggen op de Gitea registry (voor docker pull)
|
|
# echo "${{ secrets.REGISTRY_TOKEN }}" | \
|
|
# docker login ${{ vars.REGISTRY_URL }} \
|
|
# -u ${{ vars.REGISTRY_USER }} --password-stdin
|
|
|
|
# cd ${{ vars.DEPLOY_PATH }}
|
|
|
|
# # Nieuwste image pullen en container herstarten
|
|
# docker compose pull
|
|
# docker compose up -d
|
|
|
|
# # Oude images opruimen
|
|
# docker image prune -f |