-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME.yaml
130 lines (111 loc) · 4.17 KB
/
README.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
---
#
# This is the canonical configuration for the `README.md`
# Run `make readme` to rebuild the `README.md`
#
# Name of this project
name: github-action-preview-environment-controller
# Tags of this project
tags:
- github-action
- continous-delivery
- preview-environments
# Categories of this project
categories:
- github-action/cd
# Logo for this project
#logo: docs/logo.png
# License of this project
license: "APACHE2"
# Canonical GitHub repo
github_repo: cloudposse/github-action-preview-environment-controller
# Badges to display
badges:
- name: "Latest Release"
image: "https://img.shields.io/github/release/cloudposse/github-action-preview-environment-controller.svg"
url: "https://github.com/cloudposse/github-action-preview-environment-controller/releases/latest"
- name: "Slack Community"
image: "https://slack.cloudposse.com/badge.svg"
url: "https://slack.cloudposse.com"
related: []
# Short description of this project
description: Action to manage to deploy and purge preview environments depends on PR labels
introduction: |-
Testing Pull Request changes usually lead to having it deployed on a preview environment.
The environment can be ephemeral or pre-provisioned. In the last case, there is a countable number of preview environments.
This GitHub Action follows a pattern when the developer set PR label to specify a preview environment to deploy.
`github-action-preview-environment-controller` allow to define map of `environment => label`.
Depending on current PR labels the action outputs a list of deploy and destroy environments.
So it performs a `controller` role and does not limit deployment methods or tools.
references:
- name: "github-actions-workflows"
description: "Reusable workflows for different types of projects"
url: "https://github.com/cloudposse/github-actions-workflows"
- name: "example-github-action-release-workflow"
description: "Example application with complicated release workflow"
url: "https://github.com/cloudposse/example-github-action-release-workflow"
# How to use this project
usage: |-
Use `github-action-preview-environment-controller` in Pull Request triggered pipeline, and use it's outputs to determinate
what environments should be deployed and what cleaned up.
```yaml
name: Pull Request
on:
pull_request:
branches: [ 'main' ]
types: [opened, synchronize, reopened, closed, labeled, unlabeled]
jobs:
context:
runs-on: ubuntu-latest
steps:
- name: Preview deployments controller
uses: cloudposse/github-action-preview-environment-controller@main
id: controller
with:
labels: ${{ toJSON(github.event.pull_request.labels.*.name) }}
open: ${{ github.event.pull_request.state == 'open' }}
env-label: |
preview: deploy
qa1: deploy/qa1
qa2: deploy/qa2
outputs:
labels_env: ${{ steps.controller.outputs.labels_env }}
deploy_envs: ${{ steps.controller.outputs.deploy_envs }}
destroy_envs: ${{ steps.controller.outputs.destroy_envs }}
deploy:
runs-on: ubuntu-latest
if: ${{ needs.context.outputs.deploy_envs != '[]' }}
strategy:
matrix:
env: ${{ fromJson(needs.context.outputs.deploy_envs) }}
environment:
name: ${{ matrix.env }}
needs: [ context ]
steps:
- name: Deploy
uses: example/deploy@main
id: deploy
with:
environment: ${{ matrix.env }}
operation: deploy
destroy:
runs-on: ubuntu-latest
if: ${{ needs.context.outputs.destroy_envs != '[]' }}
strategy:
matrix:
env: ${{ fromJson(needs.context.outputs.destroy_envs) }}
needs: [ context ]
steps:
- name: Destroy
uses: example/deploy@main
id: deploy
with:
environment: ${{ matrix.env }}
operation: destroy
```
include:
- "docs/github-action.md"
# Contributors to this project
contributors:
- name: "Igor Rodionov"
github: "goruha"