mirror of
https://github.com/varunsridharan/actions-toolkit.git
synced 2025-02-22 22:52:58 +08:00
Updated
This commit is contained in:
parent
976cc40b9b
commit
89005b2617
3 changed files with 43 additions and 4 deletions
|
@ -56,6 +56,7 @@ GH_LOG::Log( 'This Text Will Be [blink]', 'normal', false, 'blink' );
|
|||
GH_LOG::Log( 'This Text Will Be [reverse]', 'normal', false, 'reverse' );
|
||||
GH_LOG::Log( 'This Text Will Be [hidden]', 'normal', false, 'hidden' );
|
||||
|
||||
|
||||
gh_log( "Input Value For VALUE2" );
|
||||
gh_log( print_r( $_ENV ) );
|
||||
print_r( gh_validate_input( 'VALUE1' ) );
|
||||
print_r( gh_validate_input( 'VALUE2' ) );
|
||||
print_r( gh_validate_input( 'VALUE3' ) );
|
||||
print_r( gh_validate_input( 'VALUE32', 'Important Input Variable Not Found !' ) );
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__ . '/php/logger.php';
|
||||
require_once __DIR__ . '/php/log-functions.php';
|
||||
require_once __DIR__ . '/php/log-functions.php';
|
||||
require_once __DIR__ . '/php/inputvar.php';
|
37
toolkit/php/inputvar.php
Normal file
37
toolkit/php/inputvar.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Checks Input Variable's Value
|
||||
*
|
||||
* @param $key
|
||||
* @param null $default
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
function gh_input( $key, $default = null ) {
|
||||
$key = sprintf( 'INPUT_%s', $key );
|
||||
if ( isset( $_ENV[ $key ] ) ) {
|
||||
return $_ENV[ $key ];
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates Input Value.
|
||||
*
|
||||
* @param $key
|
||||
* @param bool $custom_message
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
function gh_validate_input( $key, $custom_message = false ) {
|
||||
if ( null === gh_input( $key ) ) {
|
||||
$custom_message = ( false === $custom_message ) ? '%s Not Found. Please Set The Input Value using WITH in workflow file' : $custom_message;
|
||||
$custom_message = sprintf( '%s', $key );
|
||||
$custom_message = '🚨 ' . $custom_message;
|
||||
gh_log_red( $custom_message );
|
||||
die();
|
||||
}
|
||||
return gh_input( $key );
|
||||
}
|
Loading…
Reference in a new issue