{"id":15674946,"url":"https://github.com/justjavac/deno-ci","last_synced_at":"2025-05-06T23:32:28.259Z","repository":{"id":62421526,"uuid":"195922663","full_name":"justjavac/deno-ci","owner":"justjavac","description":"Get environment variables exposed by CI services","archived":false,"fork":false,"pushed_at":"2022-08-24T01:39:38.000Z","size":68,"stargazers_count":15,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-07T18:03:49.975Z","etag":null,"topics":["appveyor","bitbucket","buddy","ci","deno","git","github","github-actions","gitlab","gitlab-ci","travis-ci","vsts","vsts-integration","webhooks"],"latest_commit_sha":null,"homepage":"https://deno.land/x/ci","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/justjavac.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-09T03:04:14.000Z","updated_at":"2024-07-23T12:46:32.000Z","dependencies_parsed_at":"2022-11-01T17:32:25.121Z","dependency_job_id":null,"html_url":"https://github.com/justjavac/deno-ci","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justjavac%2Fdeno-ci","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justjavac%2Fdeno-ci/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justjavac%2Fdeno-ci/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justjavac%2Fdeno-ci/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justjavac","download_url":"https://codeload.github.com/justjavac/deno-ci/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252787180,"owners_count":21804211,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["appveyor","bitbucket","buddy","ci","deno","git","github","github-actions","gitlab","gitlab-ci","travis-ci","vsts","vsts-integration","webhooks"],"created_at":"2024-10-03T15:53:32.645Z","updated_at":"2025-05-06T23:32:28.226Z","avatar_url":"https://github.com/justjavac.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deno CI\n\n\u003e Get details about the current Continuous Integration environment.\n\n[![tag](https://img.shields.io/github/release/justjavac/deno-ci)](https://github.com/justjavac/deno-ci/releases)\n[![ci](https://github.com/justjavac/deno-ci/actions/workflows/ci.yml/badge.svg)](https://github.com/justjavac/deno-ci/actions/workflows/ci.yml)\n[![license](https://img.shields.io/github/license/justjavac/deno-ci)](https://github.com/justjavac/deno-ci/blob/main/LICENSE)\n\nSource code based on:\n\n- [watson/ci-info](https://github.com/watson/ci-info)\n- [pvdlg/env-ci](https://github.com/pvdlg/env-ci)\n- [codecov/codecov-node](https://github.com/codecov/codecov-node/blob/master/lib/detect.js)\n\n## Usage\n\n```ts\nimport * as ci from \"https://deno.land/x/ci/mod.ts\";\n\nif (ci.isCI) {\n  console.log(`Building repo ${ci.slug} on ${ci.name} service`);\n\n  if (ci.isPr) {\n    console.log(\n      `Building Pull Request #${ci.pr} originating from branch ${ci.prBranch} and targeting branch ${ci.branch}`,\n    );\n  } else {\n    console.log(`Building branch ${ci.branch}`);\n  }\n\n  if (ci.service === \"travis\") {\n    // Do something specific to Travis CI\n  }\n}\n```\n\n## Supported variables\n\n| Variable   | Description                                                                                            |\n| ---------- | ------------------------------------------------------------------------------------------------------ |\n| `name`     | CI service Commercial name (e.g. `Travis CI`, `CircleCI`, `GitLab CI/CD`)                              |\n| `service`  | Standardized CI service name (e.g. `travis`, `circleci`, `gitlab`)                                     |\n| `isCi`     | `true` is running on a CI, `false` otherwise                                                           |\n| `branch`   | Git branch being built or targeted by a Pull Request                                                   |\n| `commit`   | Commit sha that triggered the CI build                                                                 |\n| `tag`      | Git tag that triggered the CI build                                                                    |\n| `build`    | CI service build number                                                                                |\n| `buildUrl` | Link to the CI service build                                                                           |\n| `job`      | CI service job number                                                                                  |\n| `jobUrl`   | Link to the CI service job                                                                             |\n| `isPr`     | `true` if the build has been triggered by a Pull Request, `false` otherwise                            |\n| `pr`       | Pull Request number (only for builds triggered by a Pull Request)                                      |\n| `prBranch` | Git branch branch from which the Pull Request originated (only for builds triggered by a Pull Request) |\n| `slug`     | The slug (in form: owner_name/repo_name) of the repository currently being built                       |\n| `root`     | The path to the directory where the repository is being built                                          |\n\n**Note**: Some variables can be detected only on certain CI services. See\n[Supported CI](#supported-ci).\n\n**Note**: The `pr` and `prBranch` properties are only available for builds\ntriggered when a Pull Request is opened/updated and not on builds triggered by a\npush on a branch even if that branch happens to be the branch from which the\nPull Request originated.\n\n## Supported CI\n\n| CI Service (`name`)                                                                                                                     |  `service`  |       `isCi`       |          `branch`           |      `commit`      |       `tag`        |      `build`       |     `buildUrl`     |       `job`        |      `jobUrl`      |        `isPr`         |         `pr`          |      `prBranch`       |       `slug`       |       `root`       |\n| --------------------------------------------------------------------------------------------------------------------------------------- | :---------: | :----------------: | :-------------------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :-------------------: | :-------------------: | :-------------------: | :----------------: | :----------------: |\n| [AppVeyor](https://www.appveyor.com/docs/environment-variables)                                                                         | `appveyor`  | :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: |\n| [Bamboo](https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html)                                                       |  `bamboo`   | :white_check_mark: |     :white_check_mark:      | :white_check_mark: |        :x:         | :white_check_mark: | :white_check_mark: | :white_check_mark: |        :x:         |          :x:          |          :x:          |          :x:          |        :x:         | :white_check_mark: |\n| [Bitbucket](https://confluence.atlassian.com/bitbucket/environment-variables-794502608.html)                                            | `bitbucket` | :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: | :white_check_mark: |\n| [Bitrise](https://devcenter.bitrise.io/builds/available-environment-variables/#exposed-by-bitriseio)                                    |  `bitrise`  | :white_check_mark: |     :white_check_mark:      | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |        :x:         |        :x:         |  :white_check_mark:   |  :white_check_mark:   |  :white_check_mark:   | :white_check_mark: |        :x:         |\n| [Buddy](https://buddy.works/knowledge/deployments/how-use-environment-variables#default-environment-variables)                          |   `buddy`   | :white_check_mark: |     [:warning:](#buddy)     | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |        :x:         |        :x:         |  :white_check_mark:   |  :white_check_mark:   |          :x:          | :white_check_mark: |        :x:         |\n| [Buildkite](https://buildkite.com/docs/builds/environment-variables)                                                                    | `buildkite` | :white_check_mark: |     :white_check_mark:      | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |        :x:         |        :x:         |  :white_check_mark:   |  :white_check_mark:   |  :white_check_mark:   | :white_check_mark: | :white_check_mark: |\n| [CircleCI](https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables)                                                      | `circleci`  | :white_check_mark: |   [:warning:](#circleci)    | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |        :x:         |  :white_check_mark:   |  :white_check_mark:   |  :white_check_mark:   | :white_check_mark: |        :x:         |\n| [Cirrus CI](https://cirrus-ci.org/guide/writing-tasks/#environment-variables)                                                           |  `cirrus`   | :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: |\n| [AWS CodeBuild](https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html)                                     | `codebuild` | :white_check_mark: | [:warning:](#aws-codebuild) | :white_check_mark: |        :x:         | :white_check_mark: | :white_check_mark: |        :x:         |        :x:         |          :x:          |          :x:          |          :x:          |        :x:         | :white_check_mark: |\n| [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: |\n| [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:         |\n| [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: |\n| [GitHub Actions](https://developer.github.com/actions/creating-github-actions/accessing-the-runtime-environment/#environment-variables) |  `github`   | :white_check_mark: |     :white_check_mark:      | :white_check_mark: |        :x:         |        :x:         |        :x:         |        :x:         |        :x:         |  :white_check_mark:   |  :white_check_mark:   |  :white_check_mark:   | :white_check_mark: | :white_check_mark: |\n| [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: |          :x:          |          :x:          |          :x:          | :white_check_mark: | :white_check_mark: |\n| [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: |\n| [Sail CI](https://sail.ci/docs/environment-variables)                                                                                   |   `sail`    | :white_check_mark: |     [:warning:](#sail)      | :white_check_mark: |        :x:         |        :x:         |        :x:         |        :x:         |        :x:         |  :white_check_mark:   |  :white_check_mark:   |          :x:          | :white_check_mark: | :white_check_mark: |\n| [Semaphore](https://semaphoreci.com/docs/available-environment-variables.html)                                                          | `semaphore` | :white_check_mark: |   [:warning:](#semaphore)   | :white_check_mark: |        :x:         | :white_check_mark: |        :x:         | :white_check_mark: |        :x:         |  :white_check_mark:   |  :white_check_mark:   |  :white_check_mark:   | :white_check_mark: | :white_check_mark: |\n| [Shippable](http://docs.shippable.com/ci/env-vars/#stdEnv)                                                                              | `shippable` | :white_check_mark: |     :white_check_mark:      | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |        :x:         |  :white_check_mark:   |  :white_check_mark:   |  :white_check_mark:   | :white_check_mark: | :white_check_mark: |\n| [TeamCity](https://confluence.jetbrains.com/display/TCD10/Predefined+Build+Parameters)                                                  | `teamcity`  | :white_check_mark: |     :white_check_mark:      | :white_check_mark: |        :x:         | :white_check_mark: |        :x:         |        :x:         |        :x:         |          :x:          |          :x:          |          :x:          | :white_check_mark: | :white_check_mark: |\n| [Travis CI](https://docs.travis-ci.com/user/environment-variables#default-environment-variables)                                        |  `travis`   | :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: |\n| [Visual Studio Team Services](https://docs.microsoft.com/en-us/vsts/pipelines/build/variables)                                          |   `vsts`    | :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:   |        :x:         | :white_check_mark: |\n| [Wercker](http://devcenter.wercker.com/docs/environment-variables/available-env-vars#hs_cos_wrapper_name)                               |  `wercker`  | :white_check_mark: |     :white_check_mark:      | :white_check_mark: |        :x:         | :white_check_mark: | :white_check_mark: |        :x:         |        :x:         |          :x:          |          :x:          |          :x:          | :white_check_mark: | :white_check_mark: |\n\n:warning: See [Caveats](#caveats)\n\n**Note**: Unsupported properties will always be `undefined`. For example if a Ci\nservices doesn't support triggering builds when a Pull Request is\nopened/updated, `isPr` will be `undefined`.\n\n**Note**: If none of the above CI services is detected, `commit` and `branch`\nare determined based on the local Git repository, and `isCi` is determined based\non the `CI` environment variable.\n\n## API\n\n### envCi(options) =\u003e Result\n\n#### options\n\nType: `Object`\n\n#### env\n\nType: `Object`\u003cbr\u003e Default: `process.env`\n\nThe object to read environment variables from.\n\n#### cwd\n\nType: `String`\u003cbr\u003e Default: `process.cwd()`\n\nThe current working directory in which to execute `git` commands used to\ndetermine the `commit` and `branch` [Result](#result) properties in case no\n[supported CI](#supported-ci) is detected.\n\n### Result\n\nType: `Object`\n\n[Environment variables values](#supported-variables) exposed by the CI service.\n\n## Caveats\n\n### AWS CodeBuild\n\nAWS CodeBuild doesn't provide an environment variable to determine the current\nGit branch being built. In addition, it clones the repository in a\n[detached head state](https://git-scm.com/docs/git-checkout#_detached_head) so\nthe branch cannot be determined with `git rev-parse --abbrev-ref HEAD`. To work\naround this limitation, `env-ci` look for the remote branches having the same\n`HEAD` as the local detached `HEAD` to determine the branch from which the\ndetached `HEAD` was created. In the rare case where there is multiple remote\nbranches with the same `HEAD` as the local detached `HEAD`, `env-ci` will\narbitrarily pick the first one. This can lead to an inaccurate `branch` value in\nsuch circumstances.\n\n### Buddy\n\nFor builds triggered when\n[a Pull Request is opened/updated](https://buddy.works/knowledge/deployments/pull-requests),\nBuddy doesn't provide an environment variable indicating the branch from which\nthe Pull Request originated nor the target branch. It also build from a branch\nnamed `pull/\u003cPR number\u003e` so the target branch cannot be determined with a `git`\ncommand. Therefore in the case of Pull Request builds, `env-ci` will not be able\nto determine the `branch` and `prBranch` properties.\n\nSee\n[feature request](https://forum.buddy.works/t/determine-pull-request-branch-with-environment-variable/911).\n\n### CircleCI\n\nFor builds triggered when a Pull Request is opened/updated, CircleCI doesn't\nprovide an environment variable indicating the target branch. Therefore in the\ncase of Pull Request builds, `env-ci` will not be able to determine the `branch`\nproperty. However `prBranch` will be set.\n\nSee\n[feature request](https://discuss.circleci.com/t/create-a-circle-target-branch-envar/10022).\n\n## Jenkins\n\nTriggering build when a Pull Request is opened/updated is supported only via the\n[ghprb-plugin](https://github.com/jenkinsci/ghprb-plugin) and\n[gitlab-plugin](https://github.com/jenkinsci/gitlab-plugin). Therefore `env-ci`\nwill set `isPr`, `pr` and `prBranch` and define `branch` with the Pull Request\ntarget branch only if one those plugin is used.\n\n## Sail\n\nFor builds triggered when a Pull Request is opened/updated, Sail doesn't provide\nan environment variable indicating the target branch, and the one for the\ncurrent branch is set to `pull/\u003cPR number\u003e` independently of the the branch name\nfrom which the Pull Request originated. Therefore in the case of Pull Request\nbuilds, `env-ci` will not be able to determine the `branch` and `prBranch`\nproperties.\n\n## Semaphore\n\nFor builds triggered when a Pull Request is opened/updated, Semaphore doesn't\nprovide an environment variable indicating the target branch. Therefore in the\ncase of Pull Request builds, `env-ci` will not be able to determine the `branch`\nproperty. However `prBranch` will be set.\n\n### Credits\n\n- [justjavac](https://github.com/justjavac)\n- [Pierre Vanduynslager](https://github.com/pvdlg) (author of env-ci)\n- [Thomas Watson Steen](https://github.com/watson) (author of ci-info)\n\n### License\n\ndeno-ci is released under the MIT License. See the bundled [LICENSE](./LICENSE)\nfile for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustjavac%2Fdeno-ci","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustjavac%2Fdeno-ci","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustjavac%2Fdeno-ci/lists"}