Skip to content

Commit

Permalink
Automatic CI user recognition (#3936)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Farkas <[email protected]>
  • Loading branch information
mrhackcz and Daniel Farkas authored Oct 23, 2024
1 parent e9d99ca commit 549e865
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
36 changes: 18 additions & 18 deletions docs/recipe/common.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ The value of this configuration is autogenerated on access.


### keep_releases
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L48)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L54)

Number of releases to preserve in releases folder.

Expand All @@ -54,14 +54,14 @@ Number of releases to preserve in releases folder.


### repository
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L51)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L57)

Repository to deploy.



### default_timeout
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L56)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L62)

Default timeout for `run()` and `runLocally()` functions.

Expand All @@ -73,7 +73,7 @@ Set to `null` to disable timeout.


### env
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L72)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L78)

Remote environment variables.
```php
Expand All @@ -91,7 +91,7 @@ run('echo $KEY', env: ['KEY' => 'over']);


### dotenv
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L81)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L87)

Path to `.env` file which will be used as environment variables for each command per `run()`.

Expand All @@ -105,7 +105,7 @@ false


### deploy_path
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L91)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L97)

The deploy path.

Expand All @@ -121,7 +121,7 @@ Throws exception if not set.


### current_path
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L101)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L107)

Return current release path. Default to [deploy_path](/docs/recipe/common.md#deploy_path)/`current`.
```php
Expand All @@ -134,7 +134,7 @@ set('current_path', '/var/public_html');


### bin/php
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L104)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L110)

Path to the `php` bin.

Expand All @@ -147,7 +147,7 @@ return which('php');


### bin/git
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L112)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L118)

Path to the `git` bin.

Expand All @@ -157,7 +157,7 @@ return which('git');


### use_relative_symlink
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L118)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L124)

Should [bin/symlink](/docs/recipe/common.md#bin/symlink) use `--relative` option or not. Will detect
automatically.
Expand All @@ -168,7 +168,7 @@ return commandSupportsOption('ln', '--relative');


### bin/symlink
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L123)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L129)

Path to the `ln` bin. With predefined options `-nfs`.

Expand All @@ -178,7 +178,7 @@ return get('use_relative_symlink') ? 'ln -nfs --relative' : 'ln -nfs';


### sudo_askpass
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L130)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L136)

Path to a file which will store temp script with sudo password.
Defaults to `.dep/sudo_pass`. This script is only temporary and will be deleted after
Expand All @@ -194,7 +194,7 @@ The value of this configuration is autogenerated on access.
## Tasks

### deploy\:prepare {#deploy-prepare}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L139)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L145)

Prepares a new release.

Expand All @@ -213,7 +213,7 @@ This task is group task which contains next tasks:


### deploy\:publish {#deploy-publish}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L151)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L157)

Publishes the release.

Expand All @@ -228,7 +228,7 @@ This task is group task which contains next tasks:


### deploy {#deploy}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L159)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L165)

Deploys your project.

Expand All @@ -241,23 +241,23 @@ This task is group task which contains next tasks:


### deploy\:success {#deploy-success}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L168)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L174)

Deploys your project.

Prints success message


### deploy\:failed {#deploy-failed}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L177)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L183)



Hook on deploy failure.


### logs\:app {#logs-app}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L186)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/common.php#L192)

Shows application logs.

Expand Down
6 changes: 6 additions & 0 deletions recipe/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
// otherwise output of `whoami` command.
set('user', function () {
if (getenv('CI') !== false) {
$ciUserVars = ['GITLAB_USER_NAME', 'GITHUB_ACTOR', 'CIRCLE_USERNAME', 'DRONE_BUILD_TRIGGER'];
foreach ($ciUserVars as $var) {
if (($ciUser = getenv($var)) !== false) {
return $ciUser;
}
}
return 'ci';
}

Expand Down

0 comments on commit 549e865

Please sign in to comment.