Skip to content

Commit

Permalink
Set up deploy to VDS (gomzyakov#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
gomzyakov authored Apr 3, 2022
1 parent dc40951 commit 9fad237
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 78 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"

48 changes: 20 additions & 28 deletions .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ main ]

jobs:
laravel-tests:
laravel_tests:
runs-on: ubuntu-latest
services:
mysql:
Expand All @@ -28,21 +28,12 @@ jobs:
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Create Database
run: |
mkdir -p database
touch database/database.sqlite
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
- name: Run tests via PHPUnit
run: vendor/bin/phpunit

# TODO Split Unit and Feature tests

build_frontend:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -56,19 +47,20 @@ jobs:
- name: Compile assets for production
run: npm run production

# deploy:
# runs-on: ubuntu-latest
#
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# - name: Deployment
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.SSH_HOST }}
# key: ${{ secrets.SSH_PRIVATE_KEY }}
# username: ${{ secrets.SSH_USERNAME }}
# script: |
# cd /var/www/html/
# git checkout -f
# git pull origin master
deploy:
runs-on: ubuntu-latest
# TODO Manual action
needs: laravel_tests
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Deployment
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
username: ${{ secrets.SSH_USERNAME }}
# TODO composer install --allow-root --no-interaction
script: |
cd /var/www/web/sites/secretnotes.ru
git pull origin main
5 changes: 5 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
115 changes: 71 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,91 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p>
# SecretNotes

<p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>
## Deployment

## About Laravel
Несколько шагов:

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- Заводим VDS
- Вручную готовим VDS
- Задаем секретки в репозитории на GitHub

- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
### Prepare VDS

Laravel is accessible, powerful, and provides tools required for large, robust applications.
Создаём VDS-виртуалку, например в [NetAngels](https://panel.netangels.ru).

## Learning Laravel

Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
Заходим по SSH и проверяем версию PHP (`php -v). Если необходимо, [обновляемся до PHP 8](https://php.watch/articles/php-8.0-installation-update-guide-debian-ubuntu):

If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
```bash
sudo apt update
sudo apt install software-properties-common
sudo apt update
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.0-common php8.0-cli -y
```

## Laravel Sponsors
Если необходимо, доустанавливаем PHP-расширения на виртуалке:

We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
```bash
sudo apt install php8.0-xml
sudo apt install php8.0-curl
```

### Premium Partners
Вручную [устанавливаем](https://getcomposer.org/download/) Composer:

- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[Many](https://www.many.co.uk)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
- **[OP.GG](https://op.gg)**
- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)**
- **[Lendio](https://lendio.com)**
```bash
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
````

## Contributing
И делаем его доступным для вызова через `composer`:

Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
```bash
sudo mv composer.phar /usr/local/bin/composer
```


>Далее делаем всё от пользователя `web`, не `root`!!!



ssh-keygen




В репозитории на GitHub, в разделе `Settings > Secrets > Actions` задаём значения:

- `SSH_PRIVATE_KEY`. If you don’t have this you can run ssh-keygen in your server terminal to generate a new key, then run the command cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys to allow connection to the private key.
- `SSH_HOST`. This is the IP address of the server.
- `SSH_USERNAME`. This is the server username, in my case it’s root . If you don’t know your username you can use the whoami command on your server to check.

В репозитории, в разделе `Deploy keys`, задаём значение публичного ключа с виртуальной машины (получить можно через `cat ~/.ssh/id_rsa.pub`). Это позволит деплоиться через `git pull` с VDS.



/var/www/web/sites

```bash
git clone [email protected]:gomzyakov/secretnotes.git secretnotes.ru
``````
/var/www/web/sites/secretnotes.ru
php -r "file_exists('.env') || copy('.env.example', '.env');"
composer install
php artisan key:generate
chmod -R 777 storage bootstrap/cache
## Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [[email protected]](mailto:[email protected]). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9fad237

Please sign in to comment.