Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT]: Automatic CI user recognition #3936

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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