memento-dev/.gitea/workflows/deploy.yaml
GauthierWebDev dde25d6d9d
Some checks failed
Update Memento Dev on VPS / deploy (push) Has been cancelled
feat: Add start and stop application workflow jobs
2025-04-17 13:27:41 +02:00

83 lines
3.2 KiB
YAML

name: Update Memento Dev on VPS
run-name: ${{ gitea.actor }} is deploying the application on the VPS 🚀
on: [push]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered."
- name: Checkout the repository code
uses: actions/checkout@v4
- run: echo "💡 The repository has been cloned to the runner."
- name: Setup SSH to the VPS
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -H -p ${{ secrets.VPS_PORT }} ${{ secrets.VPS_HOST }} >> ~/.ssh/known_hosts
echo "🔑 SSH has been set up to the VPS."
- name: Pull main branch on the VPS
env:
VPS_USER: ${{ secrets.VPS_USER }}
VPS_HOST: ${{ secrets.VPS_HOST }}
VPS_PATH: ${{ secrets.VPS_PATH }}
VPS_PORT: ${{ secrets.VPS_PORT }}
run: |
ssh -i ~/.ssh/id_ed25519 -p $VPS_PORT $VPS_USER@$VPS_HOST "cd $VPS_PATH && git pull origin main"
echo "🚀 The main branch has been pulled on the VPS."
- name: Building the Docker services
env:
VPS_USER: ${{ secrets.VPS_USER }}
VPS_HOST: ${{ secrets.VPS_HOST }}
VPS_PATH: ${{ secrets.VPS_PATH }}
VPS_PORT: ${{ secrets.VPS_PORT }}
run: |
ssh -i ~/.ssh/id_ed25519 -p $VPS_PORT $VPS_USER@$VPS_HOST "cd $VPS_PATH && docker compose build"
echo "📦 The services have been builded on the VPS."
- name: Installing the dependencies
env:
VPS_USER: ${{ secrets.VPS_USER }}
VPS_HOST: ${{ secrets.VPS_HOST }}
VPS_PATH: ${{ secrets.VPS_PATH }}
VPS_PORT: ${{ secrets.VPS_PORT }}
run: |
ssh -i ~/.ssh/id_ed25519 -p $VPS_PORT $VPS_USER@$VPS_HOST "cd $VPS_PATH && docker compose run --rm memento-dev install"
echo "📦 The dependencies has been installed."
- name: Building the application
env:
VPS_USER: ${{ secrets.VPS_USER }}
VPS_HOST: ${{ secrets.VPS_HOST }}
VPS_PATH: ${{ secrets.VPS_PATH }}
VPS_PORT: ${{ secrets.VPS_PORT }}
run: |
ssh -i ~/.ssh/id_ed25519 -p $VPS_PORT $VPS_USER@$VPS_HOST "cd $VPS_PATH && docker compose run --rm memento-dev build"
echo "📦 The application have been builded on the VPS."
- name: Stop the application
env:
VPS_USER: ${{ secrets.VPS_USER }}
VPS_HOST: ${{ secrets.VPS_HOST }}
VPS_PATH: ${{ secrets.VPS_PATH }}
VPS_PORT: ${{ secrets.VPS_PORT }}
run: |
ssh -i ~/.ssh/id_ed25519 -p $VPS_PORT $VPS_USER@$VPS_HOST "cd $VPS_PATH && docker compose down"
echo "🚀 The application has been started on the VPS."
- name: Start the application
env:
VPS_USER: ${{ secrets.VPS_USER }}
VPS_HOST: ${{ secrets.VPS_HOST }}
VPS_PATH: ${{ secrets.VPS_PATH }}
VPS_PORT: ${{ secrets.VPS_PORT }}
run: |
ssh -i ~/.ssh/id_ed25519 -p $VPS_PORT $VPS_USER@$VPS_HOST "cd $VPS_PATH && docker compose up -d"
echo "🚀 The application has been started on the VPS."