From 0eb748fa365c40d193296f3dae34afbb7888e129 Mon Sep 17 00:00:00 2001 From: Eunjae Lee Date: Mon, 11 Apr 2022 11:17:01 +0200 Subject: [PATCH 1/6] chore(ci): get current branch name correctly on GitHub Action --- .github/actions/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index e089d22e53..0e5b82e812 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -44,7 +44,7 @@ runs: shell: bash run: | previousCommit=${{ github.event.before }} - baseRef=${{ github.base_ref }} + baseRef=${GITHUB_REF##*/} origin=$( [[ -z $baseRef ]] && echo $previousCommit || echo "origin/$baseRef" ) yarn workspace scripts setRunVariables "$origin" From 2e43991763d4a637add954b4c10c2723cb22f910 Mon Sep 17 00:00:00 2001 From: Eunjae Lee Date: Mon, 11 Apr 2022 11:38:00 +0200 Subject: [PATCH 2/6] chore: change implementation --- .github/actions/setup/action.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 0e5b82e812..4c38888699 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -38,13 +38,18 @@ runs: # We want to load the java formatter language: java + - name: Extract branch name + shell: bash + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" + id: extract_branch + - name: Setting diff outputs variables if: inputs.type != 'minimal' id: diff shell: bash run: | previousCommit=${{ github.event.before }} - baseRef=${GITHUB_REF##*/} + baseRef=${{ steps.extract_branch.outputs.branch }} origin=$( [[ -z $baseRef ]] && echo $previousCommit || echo "origin/$baseRef" ) yarn workspace scripts setRunVariables "$origin" From 2f1435bde9aa56f56b9d84d7adbd985106f252dd Mon Sep 17 00:00:00 2001 From: Eunjae Lee Date: Mon, 11 Apr 2022 11:51:22 +0200 Subject: [PATCH 3/6] chore: change implementation (2) --- .github/actions/setup/action.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 4c38888699..1ceb7e2065 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -38,18 +38,13 @@ runs: # We want to load the java formatter language: java - - name: Extract branch name - shell: bash - run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" - id: extract_branch - - name: Setting diff outputs variables if: inputs.type != 'minimal' id: diff shell: bash run: | previousCommit=${{ github.event.before }} - baseRef=${{ steps.extract_branch.outputs.branch }} + baseRef=$( [[ -z "${{ github.base_ref }}" ]] && echo ${GITHUB_REF#refs/heads/} || echo "${{ github.base_ref }}" ) origin=$( [[ -z $baseRef ]] && echo $previousCommit || echo "origin/$baseRef" ) yarn workspace scripts setRunVariables "$origin" From ff1c7edfa16d9b374eb4ce26a68f602eda1267eb Mon Sep 17 00:00:00 2001 From: Eunjae Lee Date: Mon, 11 Apr 2022 11:56:25 +0200 Subject: [PATCH 4/6] chore: change implementation (3) --- .github/actions/setup/action.yml | 2 +- scripts/ci/setRunVariables.ts | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 1ceb7e2065..e089d22e53 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -44,7 +44,7 @@ runs: shell: bash run: | previousCommit=${{ github.event.before }} - baseRef=$( [[ -z "${{ github.base_ref }}" ]] && echo ${GITHUB_REF#refs/heads/} || echo "${{ github.base_ref }}" ) + baseRef=${{ github.base_ref }} origin=$( [[ -z $baseRef ]] && echo $previousCommit || echo "origin/$baseRef" ) yarn workspace scripts setRunVariables "$origin" diff --git a/scripts/ci/setRunVariables.ts b/scripts/ci/setRunVariables.ts index abdad6a05a..d63e6bb298 100644 --- a/scripts/ci/setRunVariables.ts +++ b/scripts/ci/setRunVariables.ts @@ -109,11 +109,13 @@ async function setRunVariables({ } if (require.main === module) { - const [origin] = process.argv.slice(2); + const [originBranch = 'origin/main'] = 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 }); } From 1730fe50599e35ad91aed4f068f81b112d32c5bc Mon Sep 17 00:00:00 2001 From: Eunjae Lee Date: Mon, 11 Apr 2022 14:44:49 +0200 Subject: [PATCH 5/6] chore: update implementation to pass input to setup action --- .github/actions/setup/action.yml | 5 ++++- .github/workflows/process-release.yml | 2 ++ scripts/ci/setRunVariables.ts | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index e089d22e53..20551f1a92 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -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 @@ -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 }} origin=$( [[ -z $baseRef ]] && echo $previousCommit || echo "origin/$baseRef" ) yarn workspace scripts setRunVariables "$origin" diff --git a/.github/workflows/process-release.yml b/.github/workflows/process-release.yml index 6614e0cb00..b57833f323 100644 --- a/.github/workflows/process-release.yml +++ b/.github/workflows/process-release.yml @@ -19,6 +19,8 @@ jobs: - name: Setup id: setup uses: ./.github/actions/setup + with: + workflow_name: process-release - run: yarn workspace scripts processRelease env: diff --git a/scripts/ci/setRunVariables.ts b/scripts/ci/setRunVariables.ts index d63e6bb298..8347ea016d 100644 --- a/scripts/ci/setRunVariables.ts +++ b/scripts/ci/setRunVariables.ts @@ -109,7 +109,7 @@ async function setRunVariables({ } if (require.main === module) { - const [originBranch = 'origin/main'] = process.argv.slice(2); + const [originBranch] = process.argv.slice(2); if (!originBranch) { throw new Error( From 1d7e0100d7f11f3202fd93e9fc7331d499051ba1 Mon Sep 17 00:00:00 2001 From: Eunjae Lee Date: Mon, 11 Apr 2022 14:55:17 +0200 Subject: [PATCH 6/6] Update .github/actions/setup/action.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clément Vannicatte <20689156+shortcuts@users.noreply.github.com> --- .github/actions/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 20551f1a92..0160d554ad 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -47,7 +47,7 @@ runs: shell: bash run: | previousCommit=${{ github.event.before }} - baseref=${{ inputs.workflow_name == 'release' && 'main' || 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"