From 74df8d0bed751dad28f94575ebfd2281c5069f05 Mon Sep 17 00:00:00 2001 From: mohsinulhaq Date: Mon, 21 Oct 2019 00:52:23 +0530 Subject: [PATCH 1/2] fix branch returning incorrect value for GitHub Actions --- index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index d717c40..3888783 100644 --- a/index.js +++ b/index.js @@ -65,11 +65,11 @@ if (process.env.TRAVIS) { event = 'push' pull_request_number = process.env.CI_PR_NUMBER - sha=process.env.CI_COMMIT_ID, + sha=process.env.CI_COMMIT_ID, buildUrl=process.env.CI_BUILD_URL - + ci = 'codeship' -} else if (process.env.GITHUB_ACTION) { +} else if (process.env.GITHUB_ACTIONS) { // GitHub Actions // Reference: https://developer.github.com/actions/creating-github-actions/accessing-the-runtime-environment/ @@ -79,7 +79,8 @@ if (process.env.TRAVIS) { event = process.env.GITHUB_EVENT_NAME commit_message = '' pull_request_number = '' - branch = process.env.GITHUB_REF + // GITHUB_HEAD_REF for pull requests. For commits, GITHUB_REF is of the form refs/heads/master, for example + branch = process.env.GITHUB_HEAD_REF || process.env.GITHUB_REF && process.env.GITHUB_REF.split('/')[2] ci = 'github_actions' } else if (process.env.NETLIFY) { // Reference: https://www.netlify.com/docs/continuous-deployment/#environment-variables From 5d0871a0cb5882d880d87ad13fe834972eeaab60 Mon Sep 17 00:00:00 2001 From: mohsinulhaq Date: Thu, 31 Oct 2019 11:52:45 +0530 Subject: [PATCH 2/2] make use of public GITHUB_ACTION env var --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 3888783..5621db4 100644 --- a/index.js +++ b/index.js @@ -69,7 +69,7 @@ if (process.env.TRAVIS) { buildUrl=process.env.CI_BUILD_URL ci = 'codeship' -} else if (process.env.GITHUB_ACTIONS) { +} else if (process.env.GITHUB_ACTION) { // GitHub Actions // Reference: https://developer.github.com/actions/creating-github-actions/accessing-the-runtime-environment/