-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (71 loc) · 2.24 KB
/
detect-helm-instance-deployment.yml
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: Workflow which detects what helm instance should be deployed
on:
workflow_call:
outputs:
cluster:
description: "cluster type as dev, staging or prod"
value: ${{ jobs.detect.outputs.dev }}
instance:
description: "Returns value of instance"
value: ${{ jobs.detect.outputs.dev }}
jobs:
detect:
name: Checking deployment conditions
runs-on: ubuntu-latest
env:
COUNT: 0
outputs:
instance: ${{ steps.split.outputs.instance }}
steps:
- id: clean
name: Clean tag name
env:
REF_NAME: ${{ github.ref_name }}
run: |
echo "TAG=${REF_NAME##*/}" >> $GITHUB_ENV
- id: instance
name: Get instance
run: |
echo "INSTANCE=${TAG##*-}" >> $GITHUB_ENV
- id: cluster
name: Get cluster
run: |
echo "CLUSTER=${TAG%%-*}" >> $GITHUB_ENV
- id: out
name: Set ouptuts
run: |
echo "VALUES_FILE=${CLUSTER}/${INSTANCE}.yml" >> $GITHUB_ENV
echo "cluster=${CLUSTER}" >> $GITHUB_OUTPUT
echo "instance=${INSTANCE}" >> $GITHUB_OUTPUT
- name: Print Outputs
run: |
echo ${{ steps.out.outputs.cluster }}
echo ${{ steps.out.outputs.instance }}
- id: no-instance
if: env.INSTANCE == ''
uses: actions/github-script@v3
with:
script: |
core.setFailed(':heavy_exclamation_mark: We have no helm instances. Exiting pipeline with Fail status.')
- id: no-cluster
if: env.CLUSTER == ''
uses: actions/github-script@v3
with:
script: |
core.setFailed(':heavy_exclamation_mark: We have no cluster. Exiting pipeline with Fail status.')
- id: no-cluster
- id: no-values-file
if: [-f env.VALUES_FILE] == false
uses: actions/github-script@v3
with:
script: |
core.setFailed(':heavy_exclamation_mark: We have no values file. Exiting pipeline with Fail status.')
- id: check_files
name: Check file existence
uses: thebinaryfelix/check-file-existence-action@v1
with:
files: env.VALUES_FILE
- name: Files exist
if: steps.check_files.outputs.exists == 'true'
# Only runs if all of the files exist
run: echo "All files exist!"