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 "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 "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 "docker compose run --rm memento-dev build" echo "📦 The application have been builded on the VPS." - name: Restart 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 "docker compose restart" echo "🚀 The application has been started on the VPS."