Skip to content

Commit

Permalink
Add condition for pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
Smolevich committed Jan 6, 2020
1 parent cde6a12 commit 3cfbf08
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Bundle/CoverallsBundle/Collector/CiEnvVarsCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,24 @@ protected function fillGithubActions()
}
$this->env['CI_NAME'] = 'github-actions';

$githubEventName = $this->env['GITHUB_EVENT_NAME'];
$githubSha = $this->env['GITHUB_SHA'];
$githubRef = $this->env['GITHUB_REF'];

if (strpos($githubRef, 'refs/heads/') !== false) {
$githubRef = str_replace('refs/heads/', '', $githubRef);
$jobId = $githubSha;
} elseif ($githubEventName === 'pull_request') {
$refParts = explode('/', $githubRef);
$prNumber = $refParts[2];
$this->env['CI_PULL_REQUEST'] = $prNumber;
$this->readEnv['CI_PULL_REQUEST'] = $this->env['CI_PULL_REQUEST'];
$jobId = sprintf('%s-PR-%s', $githubSha, $prNumber);
} elseif (strpos($githubRef, 'refs/tags/') !== false) {
$githubRef = str_replace('refs/tags/', '', $githubRef);
$jobId = $githubRef;
}

$this->env['CI_JOB_ID'] = $jobId;
$this->env['CI_BRANCH'] = $githubRef;
$this->env['CI_JOB_ID'] = $jobId;
Expand Down

1 comment on commit 3cfbf08

@simPod
Copy link
Contributor

@simPod simPod commented on 3cfbf08 Jan 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Smolevich I'd just like to say that the way you copy my code into yours does not preserve any of my attribution and I consider it a bit unfair. Especially when I prepared easy to merge PR for you.

Please sign in to comment.