summaryrefslogtreecommitdiffstats
path: root/pkg/runner/testdata/actions-environment-and-context-tests/docker/entrypoint.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/runner/testdata/actions-environment-and-context-tests/docker/entrypoint.sh')
-rwxr-xr-xpkg/runner/testdata/actions-environment-and-context-tests/docker/entrypoint.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/pkg/runner/testdata/actions-environment-and-context-tests/docker/entrypoint.sh b/pkg/runner/testdata/actions-environment-and-context-tests/docker/entrypoint.sh
new file mode 100755
index 0000000..a954fd4
--- /dev/null
+++ b/pkg/runner/testdata/actions-environment-and-context-tests/docker/entrypoint.sh
@@ -0,0 +1,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