diff --git a/test/php.php b/test/php.php index d70f3a2..6e56a9b 100644 --- a/test/php.php +++ b/test/php.php @@ -61,5 +61,19 @@ gh_log( gh_input( 'VALUE1' ) ); gh_log( gh_input( 'VALUE2' ) ); gh_log( gh_input( 'VALUE3' ) ); gh_log( gh_input( 'VALUE4', 'DEFAULT_VALUE' ) ); -gh_validate_input( 'VALUE5', 'Sorry Can\'t Process VALUE5 Input Is Required' ); -gh_validate_input( 'VALUE6' ); +#gh_validate_input( 'VALUE5', 'Sorry Can\'t Process VALUE5 Input Is Required' ); +#gh_validate_input( 'VALUE6' ); + +# Sets A New ENV Variable And Logs A Success Message +gh_set_env( "ENV_VAR_NAME", "ENV_VAR_CONTENT" ); +gh_set_env( "ENV_VAR_NAME2", "ENV_VAR_CONTENT" ); + +# Sets A New ENV Variable And No Log Will Be Generated +gh_set_env_silent( "ENV_VAR_NAME3", "Custom Content Here" ); + +# Sets A New ENV Variable Which Will have Multiple Lines Of String +gh_set_env_multiline( "VARIABLE_NAME", "Lorem Ipsum is simply dummy text of the printing and typesetting industry. +Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. +It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. +It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, +and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum." ); diff --git a/toolkit/php.php b/toolkit/php.php index 35604fc..112d6e0 100644 --- a/toolkit/php.php +++ b/toolkit/php.php @@ -2,4 +2,5 @@ require_once __DIR__ . '/php/logger.php'; require_once __DIR__ . '/php/log-functions.php'; -require_once __DIR__ . '/php/inputvar.php'; \ No newline at end of file +require_once __DIR__ . '/php/inputvar.php'; +require_once __DIR__ . '/php/env.php'; \ No newline at end of file diff --git a/toolkit/php/env.php b/toolkit/php/env.php new file mode 100644 index 0000000..988765f --- /dev/null +++ b/toolkit/php/env.php @@ -0,0 +1,41 @@ +> $GITHUB_ENV'; + echo 'echo "' . addslashes( $value ) . '" >> $GITHUB_ENV'; + echo 'echo "EOF" >> $GITHUB_ENV'; + if ( ! $silent ) { + gh_log( "✔️ ENV : ${key} => ${value}" ); + } + +} + +function gh_set_env( $key, $value, $silent = false ) { + echo 'echo "' . $key . '=' . $value . '" >> $GITHUB_ENV'; + if ( ! $silent ) { + gh_log( "✔️ ENV : ${key} => ${value}" ); + } + +} + +function gh_set_env_silent( $key, $value ) { + gh_set_env( $key, $value, true ); +}