mirror of
https://github.com/varunsridharan/actions-toolkit.git
synced 2025-02-23 23:23:47 +08:00
Updated.
This commit is contained in:
parent
ef8680db7b
commit
53e399c3ac
2 changed files with 27 additions and 0 deletions
|
@ -8,6 +8,7 @@ require_once __DIR__ . '/php/inputvar.php';
|
|||
require_once __DIR__ . '/php/env.php';
|
||||
require_once __DIR__ . '/php/general-functions.php';
|
||||
|
||||
define( 'GITHUB_REPOSITORY', gh_env( 'GITHUB_REPOSITORY' ) . '/' );
|
||||
define( 'GH_WORKSPACE', gh_env( 'GITHUB_WORKSPACE' ) . '/' );
|
||||
define( 'GH_REF_BRANCH', trim( str_replace( 'refs/heads/', '', gh_env( 'GITHUB_REF' ) ) ) );
|
||||
|
||||
|
|
|
@ -55,4 +55,30 @@ function validate_save_path( $dest_path, $default_filename = '' ) {
|
|||
@mkdir( GH_WORKSPACE . $base_dirname, 0777, true );
|
||||
}
|
||||
return $dest_path;
|
||||
}
|
||||
|
||||
function github_url( $raw = false, $repository = false, $branch = false, $file_path = false ) {
|
||||
$url = ( $raw ) ? 'https://raw.githubusercontent.com/' : 'https://github.com/';
|
||||
|
||||
if ( false !== $repository ) {
|
||||
$repository = ( empty( $repository ) ) ? GITHUB_REPOSITORY : $repository;
|
||||
$url .= $repository . '/';
|
||||
}
|
||||
|
||||
if ( false !== $branch ) {
|
||||
$branch = ( empty( $branch ) ) ? GH_REF_BRANCH : $branch;
|
||||
$url .= ( $raw ) ? 'blob/' : '';
|
||||
$url .= $branch . '/';
|
||||
}
|
||||
|
||||
if ( false !== $file_path ) {
|
||||
$url .= ( ! empty( $file_path ) ) ? $file_path : '';
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
function gh_commit( $file, $commit_msg = 'File Updated' ) {
|
||||
shell_exec( 'git add -f ' . GH_WORKSPACE . $file );
|
||||
shell_exec( 'git commit -m "' . $commit_msg . '" ' );
|
||||
}
|
Loading…
Reference in a new issue