Reputation: 1067
Let's take this workflow as an example which is based on the NodeJS starter workflow.
name: continues integration workflow
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v2
- name: setup node
uses: actions/setup-node@v1
with:
node-version: '13.x'
- run: npm test
env:
CI: true
What is the purpose of setting CI: true
?
Upvotes: 7
Views: 3938
Reputation: 1327544
Note that since April 2020, you will not see anymore
env:
CI: true
That is because CI
is now always set to true, by default.
As noted, this will allow for a script to check if it is running within the context of a CI/CD environment. You find the same convention in GitLab
Mark that job is executed in CI environment
Upvotes: 7
Reputation: 14816
As far as I can tell, the CI
variable is there for compatibility with other CI systems. Here are the facts as I know them:
CI
variable.CI=1
.CI=true
, since it is not intended for CI only. Instead, it sets GITHUB_ACTIONS=true
.CI
variable, is so that your tests and app configuration can check for its existence, and do something differently if they need to (for example, skip certain tests on CI, or configure a different setting when on CI).If your code and test code do not have the CI
variable in them, then you can probably omit this setting and have the same result.
Upvotes: 5