-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (80 loc) · 2.84 KB
/
promote.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
name: Promote
on:
workflow_dispatch:
inputs:
application:
description: Application to promote
required: true
type: choice
options:
- podinfo
source:
description: From source environment
required: true
type: choice
options:
- dev-1-aws-us-east-1
- prd-5-aws-us-east-1
- prd-6-aws-eu-west-1
- prd-7-gcp-europe-west1
- prd-8-gcp-us-central1
- stg-3-aws-us-east-1
- stg-4-gcp-europe-west1
- tst-2-aws-us-east-1
target:
description: To target environment
required: true
type: choice
options:
- dev-1-aws-us-east-1
- prd-5-aws-us-east-1
- prd-6-aws-eu-west-1
- prd-7-gcp-europe-west1
- prd-8-gcp-us-central1
- stg-3-aws-us-east-1
- stg-4-gcp-europe-west1
- tst-2-aws-us-east-1
branch:
description: Branch name
required: true
type: string
jobs:
promote:
runs-on: ubuntu-latest
name: Promote
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Extract source components
# get the components, ignore mixins, and write them to a file
run: |
yq '[.components[] | select(test("(../)*mixins/") == false)]' \
environments/${{inputs.source}}/${{inputs.application}}/kustomization.yaml >> components.yaml
- name: Extract target components
# use all components from source
run: |
yq '.components' \
environments/${{inputs.target}}/${{inputs.application}}/kustomization.yaml >> components.yaml
- name: Write new components
run: |
yq -i '.components |= load("components.yaml")' \
environments/${{inputs.target}}/${{inputs.application}}/kustomization.yaml
- name: Sort components
run: |
yq -i '.components |= (unique | sort) ' \
environments/${{inputs.target}}/${{inputs.application}}/kustomization.yaml
- name: Cleanup
run: rm components.yaml
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
draft: true
commit-message: Promote ${{ inputs.source }} to ${{ inputs.target }}
branch: ${{inputs.branch}}
delete-branch: true
title: Promote ${{ inputs.source }} to ${{ inputs.target }}
body: |
This automatically created pull request will not trigger workflows
with the `push` and/or `pull_request` triggers due
to [Github's recursing protection](https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs).
Manually close and reopen this pull request so the required actions are executed.