@@ -28,7 +28,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
2828 } ) ;
2929} ;
3030Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
31- exports . getBumperState = exports . getTrigger = exports . normalizeFiles = exports . getFiles = exports . getBumperOptions = exports . getBranchFromRef = exports . getSchemeDefinition = exports . normalizeOptions = void 0 ;
31+ exports . getBumperState = exports . getTrigger = exports . normalizeFiles = exports . getFiles = exports . getBumperOptions = exports . getBranchFromTrigger = exports . getSchemeDefinition = exports . normalizeOptions = void 0 ;
3232const definedSchemes = __importStar ( require ( "../schemes.json" ) ) ;
3333const utils_1 = require ( "./utils" ) ;
3434const core = __importStar ( require ( "@actions/core" ) ) ;
@@ -74,13 +74,28 @@ function getSchemeDefinition(options) {
7474exports . getSchemeDefinition = getSchemeDefinition ;
7575/**
7676 * Get Branch name from reference
77- * @param ref
77+ * Only tested with the GITHUB_REF env var
78+ * @param trigger
7879 */
79- function getBranchFromRef ( ref ) {
80- const refPath = ref . split ( '/' ) ;
81- return refPath [ refPath . length - 1 ] ; // last string in the ref is the branch name
80+ function getBranchFromTrigger ( trigger ) {
81+ var _a ;
82+ let branch ;
83+ switch ( trigger ) {
84+ case 'pull-request' :
85+ branch = process . env . GITHUB_HEAD_REF || '' ;
86+ break ;
87+ case 'commit' :
88+ case 'manual' :
89+ default :
90+ branch = ( ( _a = process . env . GITHUB_REF ) === null || _a === void 0 ? void 0 : _a . substring ( 'refs/heads/' . length ) ) || '' ;
91+ break ;
92+ }
93+ core . info ( `process.env.GITHUB_HEAD_REF: ${ process . env . GITHUB_HEAD_REF } ` ) ;
94+ core . info ( `process.env.GITHUB_REF: ${ process . env . GITHUB_REF } ` ) ;
95+ core . info ( `Current Branch identified: ${ branch } ` ) ;
96+ return branch ;
8297}
83- exports . getBranchFromRef = getBranchFromRef ;
98+ exports . getBranchFromTrigger = getBranchFromTrigger ;
8499/**
85100 * Get all bumper options
86101 */
@@ -226,12 +241,12 @@ function getTrigger() {
226241 return 'commit' ;
227242 case 'pull_request' :
228243 return 'pull-request' ;
229- case 'pull_request_review_comment' :
230- return 'pr-comment' ;
244+ // case 'pull_request_review_comment':
245+ // return 'pr-comment';
231246 case 'workflow_dispatch' :
232247 return 'manual' ;
233248 default :
234- console . warn ( "Event trigger not of type: commit, pull request or pr-comment ." ) ;
249+ console . warn ( "Event trigger not of type: commit, pull request or manual ." ) ;
235250 throw new Error ( "Invalid trigger event" ) ;
236251 }
237252}
@@ -242,7 +257,7 @@ exports.getTrigger = getTrigger;
242257 */
243258function getBumperState ( options ) {
244259 return __awaiter ( this , void 0 , void 0 , function * ( ) {
245- const branch = getBranchFromRef ( process . env . GITHUB_REF || '' ) , schemeRegExp = utils_1 . getSchemeRegex ( options ) , schemeDefinition = getSchemeDefinition ( options ) , curVersion = yield utils_1 . getCurVersion ( options ) , trigger = getTrigger ( ) , tag = utils_1 . getTag ( options , trigger , branch ) , newVersion = yield utils_1 . bumpVersion ( options , trigger , branch ) , files = getFiles ( options ) ;
260+ const trigger = getTrigger ( ) , branch = getBranchFromTrigger ( trigger ) , schemeRegExp = utils_1 . getSchemeRegex ( options ) , schemeDefinition = getSchemeDefinition ( options ) , curVersion = yield utils_1 . getCurVersion ( options ) , tag = utils_1 . getTag ( options , trigger , branch ) , newVersion = yield utils_1 . bumpVersion ( options , trigger , branch ) , files = getFiles ( options ) ;
246261 const state = {
247262 curVersion,
248263 newVersion,
@@ -253,7 +268,7 @@ function getBumperState(options) {
253268 branch,
254269 files
255270 } ;
256- console . log ( `State -> ${ JSON . stringify ( state ) } ` ) ;
271+ core . info ( `State -> ${ JSON . stringify ( state ) } ` ) ;
257272 return state ;
258273 } ) ;
259274}
0 commit comments