@@ -9,12 +9,6 @@ Tutorial duration: **10 min**
99
1010First, [ install the Deployer] ( installation.md ) .
1111
12- ## Initialize Deployer
13-
14- Let's say you have an app called ** myapp** and we want to deploy it. The
15- ** myapp** repository is ** github.com/myorg/myapp** and we want to deploy it to
16- ** example.com** .
17-
1812Let's ` cd ` into our app repo and run following command:
1913
2014``` bash
@@ -24,6 +18,8 @@ dep init
2418Deployer will ask you a few question and after finishing you will have a
2519` deploy.php ` or ` deploy.yaml ` file.
2620
21+ All framework recipes based on [ common] ( recipe/common.md ) recipe.
22+
2723## Provision a server
2824
2925::: note
@@ -36,8 +32,8 @@ Make sure what image is `Ubuntu 20.04 LTS` as this version is supported via
3632Deployer [ provision] ( recipe/provision.md ) recipe.
3733
3834::: tip
39- Configure Reverse DNS or RDNS on your server, this allow you to ssh into server
40- using domain name instead of IP address.
35+ Configure Reverse DNS or RDNS on your server, this will allow you to ssh into
36+ server using domain name instead of IP address.
4137:::
4238
4339After VPS created, let's try to ssh as root:
@@ -59,7 +55,9 @@ provisioning.
5955Deployer will ask you a few questions during provisioning like PHP version,
6056database type, etc.
6157
62- Provision will take ~ 5min.
58+ Provision will take around ** ~ 5min** and install everything we need to run a
59+ site. Also, it will configure ` deployer ` user what we need to use to ssh to our
60+ host and a new website was configured at [ deploy_path] ( recipe/common.md#deploy_path ) .
6361
6462After we have configured webserver let's deploy our
6563app.
@@ -71,11 +69,73 @@ Let's deploy our application:
7169dep deploy
7270```
7371
74- Now let's ssh to host and edit ` .env ` .
72+ Now we can ssh to host and edit, for example, ` .env ` .
7573
7674``` bash
7775dep ssh
7876```
7977
78+ Also let's add a build step on our host:
79+ ``` phpr
80+ task('build', function () {
81+ cd('{{release_path}}');
82+ run('npm install');
83+ run('npm run prod');
84+ });
85+
86+ after('deploy:update_code', 'build');
87+ ```
88+
89+ Also, Deployer has a useful task for examine what is currently deployed.
90+ ``` bash
91+ $ dep releases
92+ task releases
93+ +---------------------+-------------+------ exemple.org ------------------+
94+ | Date (UTC) | Release | Author | Target | Commit |
95+ +---------------------+-------------+----------------+--------+-----------+
96+ | 2021-11-05 14:00:22 | 1 (current) | Anton Medvedev | HEAD | 943ded2be |
97+ +---------------------+-------------+----------------+--------+-----------+
98+ ```
99+
100+ ::: tip
101+ During development [ dep push] ( recipe/deploy/push.md ) task maybe useful.
102+ :::
80103
81104## Deploy on push
105+
106+ Not let's use [ GitHub Action for Deployer] ( https://github.com/deployphp/action ) .
107+
108+ Create ` .github/workflows/deploy.yml ` file with following content:
109+
110+ ``` yaml
111+ name : deploy
112+
113+ on :
114+ push :
115+ branches : [ master ]
116+
117+ concurrency : production_environment
118+
119+ jobs :
120+ deploy :
121+ runs-on : ubuntu-latest
122+
123+ steps :
124+ - uses : actions/checkout@v2
125+
126+ - name : Setup PHP
127+ uses : shivammathur/setup-php@v2
128+ with :
129+ php-version : ' 8.0'
130+
131+ - name : Deploy
132+ uses : deployphp/action@v1
133+ with :
134+ private-key : ${{ secrets.PRIVATE_KEY }}
135+ dep : deploy
136+ ` ` `
137+
138+ :::warning
139+ The ` concurrency: production_environment` is important as it prevents concurrent
140+ deploys.
141+ :: :
0 commit comments