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

feat(github): add buildUrl #194

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ if (isCI) {
| [Codefresh](https://codefresh.io/docs/docs/codefresh-yaml/variables#system-provided-variables) | `codefresh` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| [Codeship](https://documentation.codeship.com/basic/builds-and-configuration/set-environment-variables/#default-environment-variables) | `codeship` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: | :x: |
| [Drone](https://readme.drone.io/reference/environ/) | `drone` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| [GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables) | `github` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| [GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables) | `github` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| [GitLab CI/CD](https://docs.gitlab.com/ce/ci/variables/README.html) | `gitlab` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| [Jenkins](https://wiki.jenkins.io/display/JENKINS/Building+a+software+project) | `jenkins` | :white_check_mark: | [:warning:](#jenkins) | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :x: | :x: | [:warning:](#jenkins) | [:warning:](#jenkins) | [:warning:](#jenkins) | :white_check_mark: | :white_check_mark: |
| [Netlify](https://docs.netlify.com/configure-builds/environment-variables/#netlify-configuration-variables) | `netlify` | :white_check_mark: | [:warning:](#netlify) | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
Expand Down
1 change: 1 addition & 0 deletions services/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module.exports = {
service: "github",
commit: env.GITHUB_SHA,
build: env.GITHUB_RUN_ID,
buildUrl: `${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/runs/${env.GITHUB_RUN_ID}`,
isPr,
branch,
prBranch: isPr ? branch : undefined,
Expand Down
11 changes: 11 additions & 0 deletions test/services/github.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const env = {
GITHUB_REPOSITORY: 'owner/repo',
GITHUB_WORKSPACE: '/workspace',
GITHUB_RUN_ID: '1246789',
GITHUB_SERVER_URL: 'https://github.com',
};

test('Push', (t) => {
Expand All @@ -20,6 +21,7 @@ test('Push', (t) => {
service: 'github',
commit: '1234',
build: '1246789',
buildUrl: 'https://github.com/owner/repo/runs/1246789',
branch: 'master',
isPr: false,
prBranch: undefined,
Expand All @@ -34,6 +36,7 @@ test('Push - with short branch name', (t) => {
service: 'github',
commit: '1234',
build: '1246789',
buildUrl: 'https://github.com/owner/repo/runs/1246789',
branch: 'master',
isPr: false,
prBranch: undefined,
Expand Down Expand Up @@ -61,6 +64,7 @@ test('PR - with event.json file', (t) => {
service: 'github',
commit: '1234',
build: '1246789',
buildUrl: 'https://github.com/owner/repo/runs/1246789',
branch: 'master',
isPr: true,
prBranch: 'refs/pull/10/merge',
Expand Down Expand Up @@ -90,6 +94,7 @@ test('PR - target', (t) => {
service: 'github',
commit: '1234',
build: '1246789',
buildUrl: 'https://github.com/owner/repo/runs/1246789',
branch: 'master',
isPr: true,
prBranch: 'refs/pull/10/merge',
Expand Down Expand Up @@ -119,6 +124,7 @@ test('PR - with event.json file and short branch name', (t) => {
service: 'github',
commit: '1234',
build: '1246789',
buildUrl: 'https://github.com/owner/repo/runs/1246789',
branch: 'master',
isPr: true,
prBranch: 'refs/pull/10/merge',
Expand All @@ -144,6 +150,7 @@ test('PR - with missing event.json file', (t) => {
service: 'github',
commit: '1234',
build: '1246789',
buildUrl: 'https://github.com/owner/repo/runs/1246789',
branch: undefined,
isPr: true,
prBranch: 'refs/pull/10/merge',
Expand All @@ -165,6 +172,7 @@ test('PR - with missing event.json file path', (t) => {
commit: '1234',
build: '1246789',
branch: undefined,
buildUrl: 'https://github.com/owner/repo/runs/1246789',
isPr: true,
prBranch: 'refs/pull/10/merge',
pr: undefined,
Expand Down Expand Up @@ -193,6 +201,7 @@ test('PR - with missing "pull_request" in event.json file', (t) => {
service: 'github',
commit: '1234',
build: '1246789',
buildUrl: 'https://github.com/owner/repo/runs/1246789',
branch: undefined,
isPr: true,
prBranch: 'refs/pull/10/merge',
Expand Down Expand Up @@ -222,6 +231,7 @@ test('PR - with missing "pull_request.base" in event.json file', (t) => {
service: 'github',
commit: '1234',
build: '1246789',
buildUrl: 'https://github.com/owner/repo/runs/1246789',
branch: undefined,
isPr: true,
prBranch: 'refs/pull/10/merge',
Expand All @@ -238,6 +248,7 @@ test('Push - with incorrect branch name', (t) => {
service: 'github',
commit: '1234',
build: '1246789',
buildUrl: 'https://github.com/owner/repo/runs/1246789',
branch: undefined,
isPr: false,
prBranch: undefined,
Expand Down