homelab/.gitea/workflows/deploy-to-fighter.yml

54 lines
1.8 KiB
YAML

name: Deploy to Fighter
run-name: ${{ gitea.actor }} deploying
on:
push:
paths:
- 'fighter/**'
jobs:
Deploy:
runs-on: fighter
steps:
- name: Pull latest code onto host via SSH
uses: appleboy/ssh-action@master
with:
host: ${{ vars.SSH_HOST_IP_FIGHTER }} # this is a LAN IP
username: ${{ vars.SSH_USERNAME_FIGHTER }}
key: ${{ secrets.SSH_KEY_DEPLOY_TO_FIGHTER }}
script: |
cd ~/homelab
git pull
- name: Validate compose configs
uses: appleboy/ssh-action@master
with:
host: ${{ vars.SSH_HOST_IP_FIGHTER }} # this is a LAN IP
username: ${{ vars.SSH_USERNAME_FIGHTER }}
key: ${{ secrets.SSH_KEY_DEPLOY_TO_FIGHTER }}
script: |
for stack in /home/$USER/homelab/fighter/config/*
do cd $stack &&
echo "===== Validating $(basename $PWD) =====" &&
docker compose config > /dev/null
done
- name: Deploy new config
uses: appleboy/ssh-action@master
with:
host: ${{ vars.SSH_HOST_IP_FIGHTER }} # this is a LAN IP
username: ${{ vars.SSH_USERNAME_FIGHTER }}
key: ${{ secrets.SSH_KEY_DEPLOY_TO_FIGHTER }}
script: |
for stack in /home/$USER/homelab/fighter/config/*
do cd $stack &&
echo "===== Deploying $(basename $PWD) =====" &&
docker compose up -d
done
Notify:
runs-on: fighter
steps:
- name: Discord notifications
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: '${{ github.repository }} deploy to fighter: ${{ job.status }}'