github.com/nektos/act@v0.2.63-0.20240520024548-8acde99bfa9c/pkg/runner/testdata/actions-environment-and-context-tests/docker/entrypoint.sh (about)

     1  #!/bin/sh
     2  
     3  checkEnvVar() {
     4  	name=$1
     5  	value=$2
     6  	allowEmpty=$3
     7  
     8  	if [ -z "$value" ]; then
     9  		echo "Missing environment variable: $name"
    10  		exit 1
    11  	fi
    12  
    13  	if [ "$allowEmpty" != "true" ]; then
    14  		test=$(echo "$value" |cut -f 2 -d "=")
    15  		if [ -z "$test" ]; then
    16  			echo "Environment variable is empty: $name"
    17  			exit 1
    18  		fi
    19  	fi
    20  
    21  	echo "$value"
    22  }
    23  
    24  checkEnvVar "GITHUB_ACTION" "$(env |grep "GITHUB_ACTION=")" false
    25  checkEnvVar "GITHUB_ACTION_REPOSITORY" "$(env |grep "GITHUB_ACTION_REPOSITORY=")" true
    26  checkEnvVar "GITHUB_ACTION_REF" "$(env |grep "GITHUB_ACTION_REF=")" true