From 3b58a838e4bd1708689a1bdd5ef7b335a12a7e1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Guillaume?= Date: Mon, 15 Jan 2024 16:18:10 +0100 Subject: [PATCH] feat: add ci vps ovh vuejs 3 --- .github/workflows/deploy-app.yml | 46 ++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/.github/workflows/deploy-app.yml b/.github/workflows/deploy-app.yml index d02d2e9..daa7359 100644 --- a/.github/workflows/deploy-app.yml +++ b/.github/workflows/deploy-app.yml @@ -1,38 +1,56 @@ -name: 🚀 Deploy app to o2switch +name: 🚀 Deploy Vue.js 3 App to VPS on: push: branches: [ 'main' ] + paths: + - 'app/**' pull_request: branches: [ 'main' ] + paths: + - 'app/**' workflow_dispatch: jobs: deploy: runs-on: ubuntu-latest + env: + APP_DIR: /var/www/aparteasy.dibodev.com steps: - name: 🚚 Get latest code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 🚀 Setup Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: '16.x' + node-version: 18 - name: 🔍 Install dependencies - run: cd app && npm install + run: cd app && npm install - name: 🧱 Build application run: cd app && npm run build - - name: 📂 Sync files - uses: SamKirkland/FTP-Deploy-Action@v4.3.4 + - name: 📤 Deploy to VPS + uses: easingthemes/ssh-deploy@main with: - server: ${{ secrets.FTP_SERVER }} - username: ${{ secrets.FTP_USERNAME }} - password: ${{ secrets.FTP_PASSWORD }} - port: 21 - protocol: ftp - local-dir: ./app/dist/ - server-dir: aparteasy.dibodev.com/ + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + ARGS: "-azrut --delete" + SOURCE: "app/dist/" + REMOTE_HOST: ${{ secrets.SSH_HOST }} + REMOTE_USER: ${{ secrets.SSH_USERNAME }} + REMOTE_PORT: ${{ secrets.SSH_PORT }} + TARGET: ${{ env.APP_DIR }} + SCRIPT_BEFORE: | + if ! command -v rsync &> /dev/null + then + echo "rsync could not be found, installing..." + sudo apt-get update + sudo apt-get install -y rsync + else + echo "rsync is already installed." + fi + echo "Starting deployment..." + SCRIPT_AFTER: | + echo "Vue.js app deployed successfully!"