47 lines
1.1 KiB
YAML
47 lines
1.1 KiB
YAML
name: Build and Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
|
|
env:
|
|
REGISTRY: git.test
|
|
IMAGE: git.test/torscha/sveltekit-app:latest
|
|
DEPLOY_PATH: /opt/apps/sveltekit-app
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Login to Gitea Registry
|
|
run: |
|
|
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login $REGISTRY \
|
|
-u "${{ secrets.REGISTRY_USER }}" \
|
|
--password-stdin
|
|
|
|
- name: Build Docker image
|
|
run: |
|
|
docker build -t $IMAGE .
|
|
|
|
- name: Push Docker image
|
|
run: |
|
|
docker push $IMAGE
|
|
|
|
- name: Deploy on Raspberry Pi
|
|
uses: appleboy/ssh-action@v1.2.0
|
|
with:
|
|
host: ${{ secrets.DEPLOY_HOST }}
|
|
port: 2222
|
|
username: ${{ secrets.DEPLOY_USER }}
|
|
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
|
script: |
|
|
cd /opt/apps/sveltekit-app
|
|
docker compose pull
|
|
docker compose up -d
|
|
docker image prune -f
|