Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): get current branch name correctly on GitHub Action #363

Merged
merged 6 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 == 'release' && 'main' || github.base_ref }}
eunjae-lee marked this conversation as resolved.
Show resolved Hide resolved
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)}`
shortcuts marked this conversation as resolved.
Show resolved Hide resolved
);
}
eunjae-lee marked this conversation as resolved.
Show resolved Hide resolved

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