Skip to content

Commit 1ef821a

Browse files
chore(ci): get current branch name correctly on GitHub Action (#363)
* chore(ci): get current branch name correctly on GitHub Action * chore: change implementation * chore: change implementation (2) * chore: change implementation (3) * chore: update implementation to pass input to setup action * Update .github/actions/setup/action.yml Co-authored-by: Clément Vannicatte <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 412665d commit 1ef821a

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

.github/actions/setup/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ inputs:
66
type:
77
description: Type of setup, `minimal` will only run the JavaScript installation.
88
required: false
9+
workflow_name:
10+
description: Name of the workflow that is executing this action.
11+
required: false
912

1013
runs:
1114
using: composite
@@ -44,7 +47,7 @@ runs:
4447
shell: bash
4548
run: |
4649
previousCommit=${{ github.event.before }}
47-
baseRef=${{ github.base_ref }}
50+
baseRef=${{ inputs.workflow_name == 'process-release' && 'main' || github.base_ref }}
4851
origin=$( [[ -z $baseRef ]] && echo $previousCommit || echo "origin/$baseRef" )
4952
5053
yarn workspace scripts setRunVariables "$origin"

.github/workflows/process-release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
- name: Setup
2020
id: setup
2121
uses: ./.github/actions/setup
22+
with:
23+
workflow_name: process-release
2224

2325
- run: yarn workspace scripts processRelease
2426
env:

scripts/ci/setRunVariables.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,13 @@ async function setRunVariables({
109109
}
110110

111111
if (require.main === module) {
112-
const [origin] = process.argv.slice(2);
112+
const [originBranch] = process.argv.slice(2);
113113

114-
if (!origin) {
115-
throw new Error(`Unable to retrieve the origin: ${origin}`);
114+
if (!originBranch) {
115+
throw new Error(
116+
`Unable to retrieve the origin branch: ${JSON.stringify(originBranch)}`
117+
);
116118
}
117119

118-
setRunVariables({ originBranch: origin });
120+
setRunVariables({ originBranch });
119121
}

0 commit comments

Comments
 (0)