Skip to content

Commit 4a28e8a

Browse files
committed
support branches with slashes
1 parent 521da8d commit 4a28e8a

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/action.ts

+6-14
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ export type State = {
5555

5656
export class Action {
5757
async pre(state: State): Promise<State> {
58-
console.log('!!! env', JSON.stringify(process.env, null, 2));
59-
console.log('!!! payload', JSON.stringify(context.payload, null, 2));
6058
state.stage = this.stage;
6159

6260
if (boolean(getInput('destroy') || 'false') === true) {
@@ -274,27 +272,21 @@ export class Action {
274272
}
275273

276274
get stage(): string {
277-
const [, branchType, branchId] = GITHUB_REF?.split('/') || [];
278-
debug(`GITHUB_REF: ${GITHUB_REF}`);
279-
debug(`GITHUB_BASE_REF: ${GITHUB_BASE_REF}`);
280-
debug(`GITHUB_HEAD_REF: ${GITHUB_HEAD_REF}`);
281-
debug(`Branch Type: ${branchType}`);
282-
debug(`Branch ID: ${branchId}`);
283-
debug(`PR Number: ${this.prNumber}`);
284-
285-
if (!branchId) {
275+
const branchName = GITHUB_REF?.split('/').slice(2).join('/') || '';
276+
debug(`Branch Name: ${branchName}`);
277+
278+
if (!branchName) {
286279
throw new Error('Unable to determine branch from GITHUB_REF');
287280
}
288281

289-
let deploymentStage = branchId;
282+
let deploymentStage = branchName.replaceAll('/', '-');
283+
290284
if (this.prNumber) {
291285
if (!GITHUB_BASE_REF) {
292286
throw new Error('Unable to determine base ref from GITHUB_BASE_REF');
293287
}
294288

295289
const normalizedBaseRef = GITHUB_BASE_REF.replaceAll('/', '-');
296-
debug('Normalized Base Ref: ' + normalizedBaseRef);
297-
298290
deploymentStage = `${normalizedBaseRef}-pr-${this.prNumber}`;
299291
}
300292

0 commit comments

Comments
 (0)