-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
93 lines (82 loc) · 2.43 KB
/
action.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
# action.yaml
name: 'KubeOne GitHub Action'
description: 'Use KubeOne with easy from GH Actions'
inputs:
command:
description: 'the command (status|apply|kubectl|version|...) to run with kubeone'
required: true
args:
description: 'extra args to pass to KubeOne'
required: false
default: ""
tfjson:
description: 'the path to the terraform json output file'
required: false
default: "./output.json"
manifest:
description: 'the path to the kubeone.yaml file'
required: false
default: "./kubeone.yaml"
credentials:
description: 'the path to the credentials.yaml file'
required: false
default: "./credentials.yaml"
version:
description: 'Version of KubeOne to use'
required: false
default: "v1.3.2"
outputs:
version:
description: "The installed KubeOne version"
value: ${{ steps.version.outputs.version }}
runs:
using: 'composite'
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.17
- name: Test if KubeOne is present
shell: bash
id: test
run: |
if $(command -v kubeone &> /dev/null)
then
echo "::set-output name=present::present"
else
echo "not present"
fi
# only Install KubeOne if its not present
- name: Install KubeOne
if: steps.test.outputs.present != 'present'
shell: bash
run: |
git clone https://github.com/kubermatic/kubeone.git
cd kubeone
git checkout ${{ inputs.version }}
go build \
-ldflags "\
-X k8c.io/kubeone/pkg/cmd.version=`git describe --tags` \
-X k8c.io/kubeone/pkg/cmd.commit=`git rev-parse HEAD` \
-X k8c.io/kubeone/pkg/cmd.date=`date +%FT%T%z` \
"\
-o kubeone \
main.go
cp kubeone /usr/local/bin/kubeone
# execute KubeOne
- name: Execute KubeOne
id: command
shell: bash
run: |
kubeone ${{ inputs.command }} \
--manifest ${{ inputs.manifest }} \
--credentials ${{ inputs.credentials }} \
--tfjson ${{ inputs.tfjson }} \
${{ inputs.args }}
# and collect the version number
- name: Extract version from Kubeone
id: version
shell: bash
run: |
sudo apt-get install -y jq > /dev/null
echo "::set-output name=version::$(kubeone version | jq -r '.kubeone.gitVersion')"