-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaction.yml
123 lines (113 loc) · 4.03 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
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
name: 'Run OpenShift/MicroShift cluster'
description: 'Run OpenShift/Microshift cluster using GH action'
inputs:
pull-secret:
description: 'pull-secret in case running OCP/Microshift.'
required: true
default: '{"auths":{"fake":{"auth": "Zm9vOmJhcgo="}}}'
preset:
description: 'preset to use for CRC microshift/okd/openshift (default microshift).'
required: true
default: 'microshift'
cpus:
description: 'number of cpu consume by crc instance'
required: false
memory:
description: 'memory in MiB consume by crc instance'
required: false
disk:
description: 'disk size consumed by crc instance'
required: false
cache:
description: 'enable cache to speed up cluster starts: true or false (default true). '
default: 'true'
runs:
using: 'composite'
steps:
- name: Check runner OS
if: ${{ runner.os != 'Linux' }}
shell: bash
run: |
echo "::error title=⛔ error hint::Support Linux Only"
exit 1
- name: Set CRC versions
if: ${{ inputs.cache == 'true' }}
shell: bash
run: |
curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/crc/latest/release-info.json
echo "crc_version=$(jq -r '.version.crcVersion' release-info.json)" >> "$GITHUB_ENV"
- name: Cache for crc binary
if: ${{ inputs.cache == 'true' }}
uses: actions/cache@v4
with:
path: installer
key: installer-${{ env.crc_version}}-${{ runner.arch }}
- name: Cache for bundle
if: ${{ inputs.cache == 'true' }}
uses: actions/cache@v4
with:
path: ~/.crc/cache
key: bundle-${{ inputs.preset}}-${{ env.crc_version }}-${{ runner.arch }}
- name: Download CRC
shell: bash
run: |
if [ ${{ runner.arch }} = "X64" ]; then
CRC_ARCH="amd64"
else
CRC_ARCH="amd64"
fi
URL="https://mirror.openshift.com/pub/openshift-v4/clients/crc/latest/crc-linux-${CRC_ARCH}.tar.xz"
mkdir -p installer
pushd installer
if [ ! -f crc-linux.tar.xz ]; then
echo "Downloading $URL"
curl -H user-agent:crc-github-action -L "$URL" -o crc-linux.tar.xz --max-time 300 --fail
SHA256SUM=$(curl -H user-agent:crc-github-action -L "${URL}".sha256 --fail)
echo "Expected sha256: $SHA256SUM"
echo "Actual sha256: $(sha256sum crc-linux.tar.xz)"
echo "$SHA256SUM crc-linux.tar.xz" | sha256sum -c
fi
tar -C /tmp -xvf crc-linux.tar.xz
sudo mv /tmp/crc-linux-*-amd64/crc /usr/bin
- name: Install required virtualization software
shell: bash
run: |
sudo apt-get update
sudo apt install -y qemu-kvm libvirt-daemon libvirt-daemon-system virtiofsd
sudo usermod -a -G libvirt $USER
- name: Set the crc config
shell: bash
env:
PRESET: ${{ inputs.preset }}
PULL_SECRET: ${{ inputs.pull-secret }}
run: |
echo "${PULL_SECRET}" > pull-secret
crc config set preset ${PRESET}
crc config set pull-secret-file pull-secret
if [ -n "${{ inputs['cpus'] }}" ]; then
echo "Using cpus: ${{ inputs['cpus'] }}"
crc config set cpus ${{ inputs['cpus'] }}
fi
if [ -n "${{ inputs['memory'] }}" ]; then
echo "Using memory: ${{ inputs['memory'] }}"
crc config set memory ${{ inputs['memory'] }}
fi
if [ -n "${{ inputs['disk'] }}" ]; then
echo "Using disk: ${{ inputs['disk'] }}"
crc config set disk-size ${{ inputs['disk'] }}
fi
- name: Setup and Start the crc
shell: bash
run: |
sudo -su $USER crc setup
sudo -su $USER crc start
sleep 60
- name: Copy OpenShift client
shell: bash
run: sudo cp /home/$USER/.crc/bin/oc/oc /usr/bin/
- name: Copy the kubeconfig file to required location
shell: bash
run: |
mkdir -p /home/$USER/.kube
cp /home/$USER/.crc/machines/crc/kubeconfig /home/$USER/.kube/config
oc get pods -A