-
Notifications
You must be signed in to change notification settings - Fork 7
/
action.yml
94 lines (89 loc) · 2.94 KB
/
action.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
82
83
84
85
86
87
88
89
90
91
92
93
94
name: 'variants-switch'
description: 'Switch to a custom variant of your deployment flavours. This requires Variants (https://github.com/Backbase/variants)'
author: 'Backbase B.V. <[email protected]>'
branding:
icon: "code"
color: "blue"
inputs:
version:
description: "Variant's version."
required: true
default: 'latest'
spec:
description: 'Specify the path to a Variants YAML configuration spec. Default is "variants.yml".'
required: false
default: 'variants.yml'
platform:
description: '"ios" or "android".'
required: false
default: 'default'
variant:
description: 'Variant you would like to switch to.'
required: true
default: 'default'
verbose:
description: 'Log tech details for nerds.'
required: true
default: false
runs:
using: "composite"
steps:
- name: Add PROJECT_PATH to GITHUB_ENV
shell: bash
run: |
echo "project_path=$(pwd)" >> $GITHUB_ENV
- name: Install variants
shell: bash
run: |
if [[ "${{ inputs.version }}" == "latest" ]];
then
brew install backbase/m/variants
else
if ! [[ "${{ inputs.version }}" =~ [[:digit:]]\.[[:digit:]]\.[[:digit:]] ]];
then
echo "❌ 'version' should match the pattern 'x.y.z'" 1>&2 && exit 1
else
brew tap backbase/m
version_in_formula=`brew info backbase/m/variants | sed -n 's/.*\(stable [[:digit:]]\.[[:digit:]]\.[[:digit:]]\).*/\1/p' | cut -d ' ' -f2`
if [[ "${{ inputs.version }}" > "$version_in_formula" ]] || [[ "${{ inputs.version }}" == "$version_in_formula" ]];
then
echo "Installing variants $version_in_formula from main formula"
brew install backbase/m/variants
else
brew install "backbase/m/variants@${{ inputs.version }}"
fi
fi
fi
- name: Variants Switch
shell: bash
run: |
echo "Repository: ${{ github.repository }}"
cd ${{ env.project_path }}
if [[ ${{ inputs.platform }} == default ]];
then
if ${{ inputs.verbose }}
then
variants switch \
--spec ${{ inputs.spec }} \
--variant ${{ inputs.variant }} \
--verbose
else
variants switch \
--spec ${{ inputs.spec }} \
--variant ${{ inputs.variant }}
fi
else
if ${{ inputs.verbose }}
then
variants switch \
--spec ${{ inputs.spec }} \
--variant ${{ inputs.variant }} \
--platform ${{ inputs.platform }} \
--verbose
else
variants switch \
--spec ${{ inputs.spec }} \
--variant ${{ inputs.variant }} \
--platform ${{ inputs.platform }}
fi
fi