Skip to content

Commit

Permalink
chore(ci): get current branch name correctly on GitHub Action (#363)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
eunjae-lee and shortcuts authored Apr 11, 2022
1 parent 92f5aaf commit cbcf0df
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ inputs:
type:
description: Type of setup, `minimal` will only run the JavaScript installation.
required: false
workflow_name:
description: Name of the workflow that is executing this action.
required: false

runs:
using: composite
Expand Down Expand Up @@ -44,7 +47,7 @@ runs:
shell: bash
run: |
previousCommit=${{ github.event.before }}
baseRef=${{ github.base_ref }}
baseRef=${{ inputs.workflow_name == 'process-release' && 'main' || github.base_ref }}
origin=$( [[ -z $baseRef ]] && echo $previousCommit || echo "origin/$baseRef" )
yarn workspace scripts setRunVariables "$origin"
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/process-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
- name: Setup
id: setup
uses: ./.github/actions/setup
with:
workflow_name: process-release

- run: yarn workspace scripts processRelease
env:
Expand Down
10 changes: 6 additions & 4 deletions scripts/ci/setRunVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@ async function setRunVariables({
}

if (require.main === module) {
const [origin] = process.argv.slice(2);
const [originBranch] = process.argv.slice(2);

if (!origin) {
throw new Error(`Unable to retrieve the origin: ${origin}`);
if (!originBranch) {
throw new Error(
`Unable to retrieve the origin branch: ${JSON.stringify(originBranch)}`
);
}

setRunVariables({ originBranch: origin });
setRunVariables({ originBranch });
}

0 comments on commit cbcf0df

Please sign in to comment.