-
Notifications
You must be signed in to change notification settings - Fork 208
/
action.yaml
118 lines (111 loc) · 4.97 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
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
name: 'install-cilium-cli'
description: 'Install Cilium CLI'
inputs:
repository:
description: 'Repository from which the release is downloaded'
default: 'cilium/cilium-cli'
release-version:
description: 'Cilium CLI release version'
ci-version:
description: 'Cilium CLI CI build version'
local-path:
description: 'Path to the local copy of the Cilium CLI repository'
default: '*/cilium-cli'
go-mod-directory:
description: >
Override the directory that contains go.mod when building the Cilium CLI
from the source. By default, This action assumes that go.mod is in the
directory specified in the local-path parameter. Set this parameter to '.'
if go.mod is in the top-level directory.
binary-dir:
description: 'Directory to store Cilium CLI executable'
required: true
default: '/usr/local/bin'
binary-name:
description: 'Cilium CLI executable name'
required: true
default: 'cilium'
skip-build:
description: 'Skip building CLI from source'
default: 'false'
image-repo:
description: 'Container image repo to download cilium-cli image from'
default: 'quay.io/cilium/cilium-cli-ci'
image-tag:
description: >
Container image tag to use. If this input parameter is specified, this
action downloads the container image and sets up Cilium CLI to be executed
inside a container.
runs:
using: "composite"
steps:
- name: Check if we should build the Cilium CLI from source
if: ${{ inputs.skip-build != 'true' }}
id: build-cli
shell: bash
run: |
CLI_PATH=$(find . -iwholename '${{ inputs.local-path }}' -type d -not -path './.git/*' -not -path './vendor/*' | sort | tail -n 1)
echo path="${CLI_PATH}" >> $GITHUB_OUTPUT
if [[ -z "${{ inputs.go-mod-directory }}" ]]; then
echo go-mod-path="${CLI_PATH}/go.mod" >> $GITHUB_OUTPUT
echo go-sum-path="${CLI_PATH}/go.sum" >> $GITHUB_OUTPUT
else
echo go-mod-path="${{ inputs.go-mod-directory }}/go.mod" >> $GITHUB_OUTPUT
echo go-sum-path="${{ inputs.go-mod-directory }}/go.sum" >> $GITHUB_OUTPUT
fi
- name: Setup Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
if: ${{ steps.build-cli.outputs.path != '' }}
with:
# renovate: datasource=golang-version depName=go
go-version: 1.23.3
cache: true
cache-dependency-path: '${{ steps.build-cli.outputs.go-sum-path }}'
- name: Build Cilium CLI from source
if: ${{ steps.build-cli.outputs.path != '' }}
shell: bash
run: |
TARGET=/tmp/cilium
make -C ${{ steps.build-cli.outputs.path }} TARGET=${TARGET}
# Install the binary in a separate step (rather than executing make install)
# to avoid building the binary as root, which would cause issues with caching.
sudo mv ${TARGET} ${{ inputs.binary-dir }}/${{ inputs.binary-name }}
- name: Check Required Version
if: ${{ steps.build-cli.outputs.path == '' && inputs.release-version == '' && inputs.ci-version == '' && inputs.image-tag == '' }}
shell: bash
run: |
echo "One of 'release-version', 'ci-version', or 'image-tag' has to be specified!"
exit 42
- name: Install Released Cilium CLI
if: ${{ steps.build-cli.outputs.path == '' && inputs.release-version != '' && inputs.ci-version == '' }}
shell: bash
run: |
curl -sSL --remote-name-all https://github.com/${{ inputs.repository }}/releases/download/${{ inputs.release-version }}/cilium-linux-amd64.tar.gz{,.sha256sum}
sha256sum --check cilium-linux-amd64.tar.gz.sha256sum
tar xzvfC cilium-linux-amd64.tar.gz /tmp
sudo mv /tmp/cilium ${{ inputs.binary-dir }}/${{ inputs.binary-name }}
rm cilium-linux-amd64.tar.gz{,.sha256sum}
- name: Install Cilium CLI from CI
if: ${{ steps.build-cli.outputs.path == '' && inputs.ci-version != '' }}
shell: bash
run: |
cid=$(docker create ${{ inputs.image-repo }}:${{ inputs.ci-version }} ls)
docker cp $cid:/usr/local/bin/cilium ${{ inputs.binary-dir }}/${{ inputs.binary-name }}
docker rm $cid
- name: Set up Cilium CLI to be executed inside a container
if: ${{ steps.build-cli.outputs.path == '' && inputs.image-tag != '' }}
shell: bash
run: |
until docker pull ${{ inputs.image-repo }}:${{ inputs.image-tag }} &> /dev/null
do
echo "Waiting for ${{ inputs.image-repo }}:${{ inputs.image-tag }} image to become available..."
sleep 10
done
export CILIUM_CLI_IMAGE_REPO=${{ inputs.image-repo }}
export CILIUM_CLI_IMAGE_TAG=${{ inputs.image-tag }}
cat ${{ github.action_path }}/.github/tools/cilium.sh | envsubst > /tmp/cilium
sudo install /tmp/cilium ${{ inputs.binary-dir }}/${{ inputs.binary-name }}
- name: Run Cilium CLI Version
shell: bash
run: |
${{ inputs.binary-dir }}/${{ inputs.binary-name }} version --client