From 5531427a7428f9a4cc936a4596cc09ec4c7687af Mon Sep 17 00:00:00 2001 From: Mhd Ramadhan Arvin <38186144+mhdramadhanarvin@users.noreply.github.com> Date: Mon, 9 Sep 2024 23:22:51 +0700 Subject: [PATCH] feat: add cd for deploy apps to hosting (#14) * feat: add cd for deploy apps to hosting * feat: adjust redis config --- .github/workflows/cd.yml | 63 ++++++++++++++++++++++++++++++++++++++++ config/database.php | 4 +++ deploy/.gitkeep | 0 3 files changed, 67 insertions(+) create mode 100644 .github/workflows/cd.yml create mode 100644 deploy/.gitkeep diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..88b2959 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,63 @@ +name: Deploy App + +"on": + push: + branches: + - main +# on: +# pull_request: +# branches: +# - main + +jobs: + tests: + name: Deploy Process + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "8.3" + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv + coverage: none + + - name: Run composer install + run: composer install -n --prefer-dist --no-dev -o + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: "20.x" + - name: Install dependencies + run: npm ci + + - name: Build App + run: npm run build + + - uses: montudor/action-zip@v1 + with: + args: zip -qq -r deploy/app.zip ./ -x ".git/*" + + - uses: SamKirkland/FTP-Deploy-Action@v4.3.4 + with: + server: ${{ secrets.FTP_SERVER }} + username: ${{ secrets.FTP_USERNAME }} + password: ${{ secrets.FTP_PASSWORD }} + protocol: ${{ vars.PROTOCOL_FTP }} + local-dir: ./deploy/ + log-level: verbose + timeout: 60000 + + - name: executing remote ssh commands using password + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.SSH_HOST }} + username: ${{ secrets.SSH_USERNAME }} + password: ${{ secrets.SSH_PASSWORD }} + port: ${{ secrets.SSH_PORT }} + script: | + cd /home/${{ secrets.SSH_USERNAME }}/stepcash + unzip -o app.zip -d /home/${{ secrets.SSH_USERNAME }}/stepcash/ + rm -rf app.zip diff --git a/config/database.php b/config/database.php index 125949e..1f700fa 100644 --- a/config/database.php +++ b/config/database.php @@ -157,6 +157,8 @@ 'password' => env('REDIS_PASSWORD'), 'port' => env('REDIS_PORT', '6379'), 'database' => env('REDIS_DB', '0'), + 'scheme' => env('REDIS_SCHEME', 'unix'), + 'path' => env('REDIS_PATH', ''), ], 'cache' => [ @@ -166,6 +168,8 @@ 'password' => env('REDIS_PASSWORD'), 'port' => env('REDIS_PORT', '6379'), 'database' => env('REDIS_CACHE_DB', '1'), + 'scheme' => env('REDIS_SCHEME', 'unix'), + 'path' => env('REDIS_PATH', ''), ], ], diff --git a/deploy/.gitkeep b/deploy/.gitkeep new file mode 100644 index 0000000..e69de29