diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 00000000..c908c50d --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,49 @@ +name: Deploy + +on: + push: + branches: [ master ] + +jobs: + build: + name: Build assets and deploy + runs-on: ubuntu-latest + + steps: + + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 7.3 + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Build assets + uses: actions/setup-node@v1 + with: + node-version: 12.x + + - run: npm install + - run: npm run build + + - name: Deploy + uses: musps/action-deployer-php@master + with: + args: deploy production + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} diff --git a/composer.json b/composer.json index 105e51d9..6726864b 100644 --- a/composer.json +++ b/composer.json @@ -82,7 +82,8 @@ } }, "require-dev": { - "deployer/deployer": "^6.0", + "deployer/deployer": "^6.8", + "deployer/recipes": "^6.2", "ichhabrecht/filefill": "^2.0" }, "config": { diff --git a/composer.lock b/composer.lock index 2cce9ba7..dc281152 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "55d1141b531b735fa5335acff314629f", + "content-hash": "bdb0e8fc25a5e98d75bea5bce07ec0bd", "packages": [ { "name": "christophlehmann/imageoptimizer", @@ -6515,6 +6515,64 @@ "abandoned": true, "time": "2019-12-12T13:45:57+00:00" }, + { + "name": "deployer/recipes", + "version": "6.2.2", + "source": { + "type": "git", + "url": "https://github.com/deployphp/recipes.git", + "reference": "84b3229c518c094a950e1fe785b7b8f9598770fe" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/deployphp/recipes/zipball/84b3229c518c094a950e1fe785b7b8f9598770fe", + "reference": "84b3229c518c094a950e1fe785b7b8f9598770fe", + "shasum": "" + }, + "require": { + "php": "~7.0" + }, + "replace": { + "deployer/recipes": "self.version" + }, + "require-dev": { + "deployer/deployer": "^6.3" + }, + "type": "library", + "autoload": { + "files": [ + "autoload.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anton Medvedev", + "email": "anton@medv.io" + } + ], + "description": "3rd party deployer recipes", + "homepage": "https://github.com/deployphp/recipes", + "keywords": [ + "cachetool", + "cloudflare", + "deploy", + "deployer", + "deployment", + "hipchat", + "newrelic", + "rabbit", + "recipes", + "sentry", + "slack", + "yarn" + ], + "abandoned": true, + "time": "2019-06-27T06:47:18+00:00" + }, { "name": "ichhabrecht/filefill", "version": "2.0.3", diff --git a/deploy.php b/deploy.php index d066990f..4820076e 100644 --- a/deploy.php +++ b/deploy.php @@ -1,15 +1,16 @@ hostname('185.237.67.190') +host('185.237.67.190') + ->stage('production') ->user('p546128') ->forwardAgent() ->multiplexing() ->set('deploy_path', '/home/www/p546128/html/{{application}}') ->set('bin/php', '/usr/local/bin/php') ->set('http_user', 'p546128') - ->set('writable_mode', 'chmod') ->set('bin/composer', '/usr/local/bin/composer') + ->set('rsync_src', __DIR__) + ->set('rsync', [ + 'exclude' => [ + '.ddev', + '.DS_Store', + '.git', + '.github', + '.idea', + 'node_modules', + 'public/fileadmin', + 'public/typo3temp', + 'public/uploads', + 'var', + '.editorconfig', + '.gitignore', + '.htaccess_prod', + 'deploy.php', + 'package.json', + 'package-lock.json', + 'postcss.config.js', + 'tailwind.config.js', + 'webpack.config.js', + ], + 'exclude-file' => false, + 'include' => [], + 'include-file' => false, + 'filter' => [], + 'filter-file' => false, + 'filter-perdir' => false, + 'flags' => 'rz', + 'options' => ['delete', 'links'], + 'timeout' => 300, + ]) + ->set('cachetool_args', '--web --web-path={{release_path}}/public/ --web-url=https://www.ep-reisen.de') ; -task('build', function () { - runLocally('npm i && npm run build'); -}); - -task('upload:epevents', function () { - upload( - __DIR__ . '/public/typo3conf/ext/ep_events/Resources/Public/', - '{{release_path}}/public/typo3conf/ext/ep_events/Resources/Public' - ); -}); - -task('upload:eptheme', function () { - upload( - __DIR__ . '/public/typo3conf/ext/ep_theme/Resources/Public/', - '{{release_path}}/public/typo3conf/ext/ep_theme/Resources/Public' - ); -}); - -task('assets', [ - 'build', - 'upload:epevents', - 'upload:eptheme', +task('deploy', [ + 'deploy:info', + 'deploy:prepare', + 'deploy:lock', + 'deploy:release', + 'rsync', + 'deploy:clear_paths', + 'deploy:shared', + 'typo3:database:migrate', + 'typo3:language:update', + 'typo3:cache:flush', + 'deploy:symlink', + 'deploy:unlock', + 'cachetool:clear:opcache', + 'cleanup', ]); -task('caches:flush', function () { - run('{{bin/php}} {{release_path}}/vendor/bin/typo3cms cache:flush'); -}); - -task('languages:update', function () { - run('{{bin/php}} {{release_path}}/vendor/bin/typo3cms language:update'); -}); - -task('database:update', function () { +task('typo3:database:migrate', function () { run('{{bin/php}} {{release_path}}/vendor/bin/typo3cms database:updateschema'); }); -before('deploy:symlink', 'assets'); -before('deploy:symlink', 'database:update'); -before('deploy:symlink', 'languages:update'); -before('cleanup', 'caches:flush'); +task('typo3:language:update', function () { + run('{{bin/php}} {{release_path}}/vendor/bin/typo3cms language:update'); +}); + +task('typo3:cache:flush', function () { + run('{{bin/php}} {{release_path}}/vendor/bin/typo3cms cache:flush'); +}); after('deploy:failed', 'deploy:unlock');