Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit 3fa3dbb

Browse files
author
Noah Hanjun Lee
authored
Evaluate the env field (#100)
* Add `Eval` to evaluate environments * Fix into a pointer for GitHub params * Add documentation for usage
1 parent 7b35d8c commit 3fa3dbb

File tree

10 files changed

+246
-120
lines changed

10 files changed

+246
-120
lines changed

docs/references/deploy.yml.md

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,44 @@
22

33
## Env
44

5-
Field |Type |Tag |Description
6-
--- |---- |--- |---
7-
`name` |*string* | |This parameter is the runtime environment such as `production`, `staging`, and `qa`.
8-
`task` |*string* |`github` |This parameter is used by the deployment system to distinguish the kind of deployment. The default values is `deploy`, but for rollback, the value is always `rollback`.
9-
`description` |*string* |`github` |This parameter is the short description of the deployment. The default value is `Gitploy starts to deploy.`
10-
`auto_merge` |*boolean* |`github` |This parameter is used to ensure that the requested ref is not behind the repository's default branch. If you deploy with the commit or the tag you need to set `false`. The default values is `true`, but for rollback, the value is always `false`.
11-
`required_contexts` |*[]string* |`github` |This parameter allows you to specify a subset of contexts that must be success. The default value is `nil`, it means every submitted context must be in a success state.
12-
`production_environment` |*boolean* |`github` |This parameter specifies whether this runtime environment is production or not.
13-
`approval` |*[Approval](#approval)* | |This parameter configures approval.
5+
6+
Field |Type |Required |Description
7+
--- |---- |--- |---
8+
`name` |*string* |`true` |This field is the runtime environment such as `production`, `staging`, and `qa`.
9+
`task` |*string* |`false` |This field is used by the deployment system to distinguish the kind of deployment.
10+
`description` |*string* |`false` |This field is the short description of the deployment.
11+
`auto_merge` |*boolean* |`false` |This field is used to ensure that the requested ref is not behind the repository's default branch. If you deploy with the commit or the tag you need to set `false`. For rollback, Gitploy set the field `false`.
12+
`required_contexts` |*[]string* |`false` |This field allows you to specify a subset of contexts that must be success.
13+
`production_environment` |*boolean* |`false` |This field specifies whether this runtime environment is production or not.
14+
`approval` |*[Approval](#approval)* |`false` |This field configures approval.
1415

1516
## Approval
1617

17-
Field |Type |Tag |Description
18-
--- |--- |--- |---
19-
`enabled` |*boolean* | |This parameter make to enable the approval feature. The default value is `false`.
20-
`required_count` |*integer* | |This parameter determine how many the required approving approvals is needs to deploy. The default value is `0`.
18+
Field |Type |Tag |Description
19+
--- |--- |--- |---
20+
`enabled` |*boolean* |`true` |This field make to enable the approval feature. The default value is `false`.
21+
`required_count` |*integer* |`false` |This field determine how many the required approving approvals is needs to deploy. The default value is `0`.
22+
23+
## Variables
24+
25+
The following variables are available in `${ }` syntax when evaluating `deploy.yml` before deploy or rollback:
26+
27+
* `GITPLOY_DEPLOY_TASK`: Returns `deploy` for deploy, but rollback, it returns the empty string.
28+
* `GITPLOY_ROLLBACK_TASK`: Returns `rollback` for rollback, but deploy, it returns the empty string.
29+
* `GITPLOY_IS_ROLLBACK`: Returns `true` for rollback, but deploy, it returns `false`.
30+
31+
An example usage of this:
32+
33+
```yaml
34+
envs:
35+
- name: prod
36+
task: "${GITPLOY_DEPLOY_TASK}${GITPLOY_ROLLBACK_TASK}:kubernetes" # It returns "deploy:kubernetes" or "rollback:kubernetes"
37+
```
2138
22-
## Tags
39+
And Gitploy provides the string operation to facilitate customized values. You can check supported functions at [here](https://github.com/drone/envsubst).
2340
24-
* `github`: Github specific field.
41+
```yaml
42+
envs:
43+
- name: prod
44+
task: "${GITPLOY_DEPLOY_TASK=rollback}:kubernetes" # It returns "deploy:kubernetes" or "rollback:kubernetes"
45+
```

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ require (
77
entgo.io/ent v0.9.0
88
github.com/AlekSi/pointer v1.1.0
99
github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef
10-
github.com/creasty/defaults v1.5.1
1110
github.com/davecgh/go-spew v1.1.1
12-
github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6 // indirect
11+
github.com/drone/envsubst v1.0.3
12+
github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6
1313
github.com/gin-contrib/cors v1.3.1
1414
github.com/gin-contrib/sse v0.1.0
1515
github.com/gin-gonic/gin v1.7.2
@@ -33,6 +33,6 @@ require (
3333
go.uber.org/zap v1.13.0
3434
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect
3535
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c
36-
gopkg.in/h2non/gock.v1 v1.1.2 // indirect
36+
gopkg.in/h2non/gock.v1 v1.1.2
3737
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
3838
)

0 commit comments

Comments
 (0)