From 9e8bdd30d94282c6fd15cb65d13b23d389866f8f Mon Sep 17 00:00:00 2001 From: ben Date: Wed, 11 Oct 2023 23:14:46 -0400 Subject: [PATCH] Added autodeploy --- .github/workflows/deploy.yml | 30 +++++++++++++++++++++++++ deploy.php | 43 ++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 deploy.php diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..f942d25 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,30 @@ +name: deploy + +on: + release: + types: [released] + +concurrency: production_environment + +jobs: + production: + runs-on: ubuntu-latest + environment: Production + + steps: + - uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "8.2" + + - name: Install dependencies + run: composer install --no-interaction --no-scripts --prefer-dist --no-dev + + + - name: Deploy + uses: deployphp/action@v1 + with: + private-key: ${{ secrets.DEPLOY_KEY }} + dep: deploy production --tag=${{ githib.ref }} diff --git a/deploy.php b/deploy.php new file mode 100644 index 0000000..aa622cc --- /dev/null +++ b/deploy.php @@ -0,0 +1,43 @@ +set('hostname', 'vps.benjamyn.love') + ->set('port', '22') + ->set('remote_user', 'root') + ->set('deploy_path'), '/opt/PriceyBotPanel'); + + +// Tasks +task('npm:build', function () { + $command = match (get('alias')) { + 'production' => 'production', + 'staging' => 'development', + default => 'production' +}; + +run("cd {{release_path}} && {{bin/npm}} run {$command}"); +}); + +// Hooks +after('deploy:vendors', 'npm:install'); +after('npm:install', 'npm:build'); +after('deploy:failed', 'deploy:unlock');