forked from apache/camel-k
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
122 lines (110 loc) · 3.96 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
# ---------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ---------------------------------------------------------------------------
name: kamel-prepare-env
description: 'Initialise the test environment with tools. (Will only run once per workflow)'
runs:
using: "composite"
steps:
- name: Set Env Vars
shell: bash
run: |
if [ "$RUNNER_OS" == "Linux" ] || [ "$RUNNER_OS" == "macOS" ]; then
SUDO=sudo
fi
echo "SUDO=${SUDO}" >> $GITHUB_ENV
#
# This is a docker action so its pre-builds the image prior to
# running it. The building occurs prior to all steps regardless
# of where its located to run. Therefore, it must be run prior to
# clean-up since that step removes all docker image in order to
# claim back as much space as possible.
#
- name: Cleanup
shell: bash
if: ${{ env.KAMEL_PREPARE_ENV != 'true' }}
run: |
echo "Initial status:"
df -h
if [ "$RUNNER_OS" == "Linux" ]; then
echo "Cleaning up resources:"
${{ env.SUDO }} swapoff -a
${{ env.SUDO }} rm -f /swapfile
${{ env.SUDO }} apt clean
${{ env.SUDO }} rm -rf /usr/share/dotnet
${{ env.SUDO }} rm -rf /opt/ghc
${{ env.SUDO }} rm -rf "/usr/local/share/boost"
${{ env.SUDO }} rm -rf "$AGENT_TOOLSDIRECTORY"
fi
if [ -x "$(command -v docker)" ]; then
df -kh
docker rmi $(docker image ls -aq) || true # Don't fail if image is not present
df -kh
fi
echo "Final status:"
df -h
- name: Set up JDK 17
uses: actions/setup-java@v4
if: ${{ env.ENV_PREPARED != 'true' }}
with:
java-version: '17'
distribution: 'temurin'
- name: Set up Go
uses: actions/setup-go@v5
if: ${{ env.KAMEL_PREPARE_ENV != 'true' }}
with:
go-version-file: 'go.mod'
check-latest: true
- name: (Re-)install kustomize
shell: bash
if: ${{ env.KAMEL_PREPARE_ENV != 'true' }}
run: |
# reinstall kustomize to be always on the same version
set +e
$(which kustomize &> /dev/null)
if [ "$?" == "0" ]; then
${{ env.SUDO }} rm $(which kustomize)
fi
set -e
make kustomize
# Add kustomize to PATH
echo "${{ env.GOPATH }}/bin" >> $GITHUB_PATH
which kustomize || { echo 'kustomize not found' ; exit 1; }
#
# Install a version of kubectl for generic access to cluster
#
- id: install-kubectl
uses: azure/setup-kubectl@v4
if: ${{ env.KAMEL_PREPARE_ENV != 'true' }}
with:
version: 'v1.28.8'
- id: install-realpath
shell: bash
if: ${{ env.KAMEL_PREPARE_ENV != 'true' }}
run : |
if [ "$RUNNER_OS" == "macOS" ] && ! [ -x "$(command -v realpath)" ]; then
echo 'Installing realpath...'
brew install coreutils
fi
- id: complete-action
name: Environment Prepared
shell: bash
if: ${{ env.KAMEL_PREPARE_ENV != 'true' }}
run : |
#
# Avoid preparing the environment repeatedly
#
echo "KAMEL_PREPARE_ENV=true" >> $GITHUB_ENV