From 50c004ca7758543956e2f2b092fba982d1afea6f Mon Sep 17 00:00:00 2001 From: Fery Wardiyanto Date: Mon, 1 Apr 2024 19:31:50 +0700 Subject: [PATCH] ci: experiment with auto deployment to idcloudhost shared-hosting Signed-off-by: Fery Wardiyanto --- .github/workflows/deploy.yml | 57 +++++++++++++++++++++++------------- composer.json | 5 ++++ storage/.gitignore | 1 + 3 files changed, 42 insertions(+), 21 deletions(-) create mode 100644 storage/.gitignore diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a9f12e1a..3b405acb 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -61,13 +61,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Cache Composer dependencies - uses: actions/cache@v4 - with: - path: ${{ needs.prepare.outputs.composer-cache }} - key: php-8.1-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: php-8.1-composer- - - name: Download assets id: download uses: actions/download-artifact@v4 @@ -75,18 +68,40 @@ jobs: name: build-${{ env.APP_ENV }} path: public - - name: Install dependencies - run: composer install --prefer-dist --no-interaction --no-progress --ansi - - - name: Deploy - uses: deployphp/action@master - env: - DB_USERNAME: ${{ secrets.DB_USERNAME }} - DB_PASSWORD: ${{ secrets.DB_PASSWORD }} - DB_RESET: ${{ github.event_name == 'workflow_dispatch' && inputs.reset || false }} - DEPLOY_ARGS: --branch ${{ needs.prepare.outputs.target-branch }} --${{ env.DB_RESET == 'true' && 'reset' || 'no-reset' }} + - name: Checkout + uses: actions/checkout@v4 with: - private-key: ${{ secrets.DEPLOY_SSH_RSAKEY }} - ssh-config: ${{ secrets.DEPLOY_SSH_CONFIG }} - verbosity: '' - dep: deploy -f scripts/deploy.php env=staging ${{ env.DEPLOY_ARGS }} + ssh-strict: false + ssh-key: ${{ secrets.DEPLOY_SSH_RSAKEY }} + repository: creasico@creasi.co:~/git/creasico-skeleton.git + path: storage/deploy-tmp + fetch-depth: 0 + + - name: Prepare deployment + run: | + composer extract + cd storage/deploy-tmp + git status + + # - name: Cache Composer dependencies + # uses: actions/cache@v4 + # with: + # path: ${{ needs.prepare.outputs.composer-cache }} + # key: php-8.1-composer-${{ hashFiles('**/composer.lock') }} + # restore-keys: php-8.1-composer- + + # - name: Install dependencies + # run: composer install --prefer-dist --no-interaction --no-progress --ansi + + # - name: Deploy + # uses: deployphp/action@master + # env: + # DB_USERNAME: ${{ secrets.DB_USERNAME }} + # DB_PASSWORD: ${{ secrets.DB_PASSWORD }} + # DB_RESET: ${{ github.event_name == 'workflow_dispatch' && inputs.reset || false }} + # DEPLOY_ARGS: --branch ${{ needs.prepare.outputs.target-branch }} --${{ env.DB_RESET == 'true' && 'reset' || 'no-reset' }} + # with: + # private-key: ${{ secrets.DEPLOY_SSH_RSAKEY }} + # ssh-config: ${{ secrets.DEPLOY_SSH_CONFIG }} + # verbosity: '' + # dep: deploy -f scripts/deploy.php env=staging ${{ env.DEPLOY_ARGS }} diff --git a/composer.json b/composer.json index 6113b913..8f13609d 100644 --- a/composer.json +++ b/composer.json @@ -78,6 +78,11 @@ "Composer\\Config::disableProcessTimeout", "dep --ansi -f scripts/deploy.php" ], + "export": [ + "git archive --format=tar --prefix=deploy-tmp/ HEAD | (cd storage && tar xf -)", + "rsync -av --exclude='*.map' public/build storage/deploy-tmp/public/", + "rm storage/deploy-tmp/public/.gitignore" + ], "fix": [ "pint --preset laravel --ansi" ], diff --git a/storage/.gitignore b/storage/.gitignore new file mode 100644 index 00000000..71a5c842 --- /dev/null +++ b/storage/.gitignore @@ -0,0 +1 @@ +/deploy-tmp