-
Notifications
You must be signed in to change notification settings - Fork 1
/
prepare.sh
executable file
·39 lines (33 loc) · 1.19 KB
/
prepare.sh
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
#!/bin/bash
set -e
OS_FLAVOR=$1
echo "Setting GitHub environment variables"
BRANCH=$(echo "${GITHUB_REF}" | awk -F / '{print $3}')
echo "::set-env name=BRANCH::${BRANCH})"
if [ -n "${GITHUB_BASE_REF}" ]; then
# this is a pull request build
PULL_REQUEST_NUMBER=$(echo "$GITHUB_REF" | awk -F / '{print $3}')
BRANCH="${GITHUB_HEAD_REF##*/}"
echo "::set-env name=OUTPUT_FOLDER::/${PULL_REQUEST_NUMBER}-${BRANCH}"
else
if [ "$BRANCH" = "master" ]; then
# this is a build from stable branch
echo "::set-env name=OUTPUT_FOLDER::/stable"
else
# this is a release build
echo "::set-env name=SEMVER_PATCH::$(date +%Y%m%d)"
echo "::set-env name=OUTPUT_FOLDER::/"
fi
fi
echo "Generating build metadata"
mkdir -p "${OS_FLAVOR}/context/etc/metal"
BUILD_META_FILE="${OS_FLAVOR}/context/etc/metal/build.yaml"
python3 - <<EOF | tee -a "${BUILD_META_FILE}"
from datetime import datetime
print(f"builddate='{datetime.now().isoformat(' ')}'")
print("commit_ref='${BRANCH}'")
print("commit_sha1='${GITHUB_SHA}'")
print("gitrepo='${GITHUB_REPOSITORY}'")
EOF
echo "remove old firecracker images"
sudo rm -rf /var/lib/firecracker/image/* /var/lib/firecracker/kernel/*