summaryrefslogtreecommitdiffstats
path: root/pkg/runner/testdata/actions-environment-and-context-tests/docker/entrypoint.sh
blob: a954fd40f9465d097a33b56ce15f8af88b89e868 (plain)
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
#!/bin/sh

checkEnvVar() {
	name=$1
	value=$2
	allowEmpty=$3

	if [ -z "$value" ]; then
		echo "Missing environment variable: $name"
		exit 1
	fi

	if [ "$allowEmpty" != "true" ]; then
		test=$(echo "$value" |cut -f 2 -d "=")
		if [ -z "$test" ]; then
			echo "Environment variable is empty: $name"
			exit 1
		fi
	fi

	echo "$value"
}

checkEnvVar "GITHUB_ACTION" "$(env |grep "GITHUB_ACTION=")" false
checkEnvVar "GITHUB_ACTION_REPOSITORY" "$(env |grep "GITHUB_ACTION_REPOSITORY=")" true
checkEnvVar "GITHUB_ACTION_REF" "$(env |grep "GITHUB_ACTION_REF=")" true