camdn/.forgejo/workflows/deploy.yml
Cameron Redmore b29f66048a
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m7s
Auto deploy after build.
2025-04-18 17:51:09 +01:00

38 lines
No EOL
1.1 KiB
YAML

name: Deploy
# Trigger the workflow manually from the Forgejo UI
on:
workflow_dispatch:
workflow_run:
workflows: ["docker-publish.yml"]
types:
- completed
jobs:
run_remote_command:
name: Execute Command on Server
runs-on: alpine-latest
steps:
- name: Setup SSH Agent
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Add known hosts
if: ${{ secrets.SSH_KNOWN_HOSTS != '' }} # Only run if the secret is set
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_KNOWN_HOSTS }}" >> ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
- name: Run Command via SSH
run: |
ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} '
echo "Running remote deployment..."
cd /home/cameron/docker/camdn/ || exit 1
docker compose pull && docker compose up -d --force-recreate
echo "Remote deployment finished."
' # End of commands for the remote server
echo "SSH command sent."