Initialize Bit for CI/CD Pipelines
This task installs Bit in your CI by executing bit install
inside the workspace directory. It uses Node 18
.
Optional The workspace directory path from the root. Default "./"
.
- Create a new secret variable for
BIT_CLOUD_ACCESS_TOKEN
(docs) and use it as an environment variable in your GitHub Action. - [Optional] Create new secret variables
GIT_USER_NAME
,GIT_USER_EMAIL
and use them as environment variables in your GitHub Action. - [Optional] Define
GITHUB_TOKEN
as an environment variable only in the workflow yaml file. Note: This token is automatically generated by GitHub Actions and is a reserved keyword in GitHub action secrets. Therefore, you don't need to create a separate secret for it. - [Optional] If your workspace is not at the root of the Git repository, specify the input parameter
ws-dir
pointing to the workspace directory path.
Note: GITHUB_TOKEN
, GIT_USER_NAME
, and GIT_USER_EMAIL
are required for tasks like bit-tasks/commit-bitmap@v1
, bit-tasks/dependency-update@v1
etc. Therefore, it is recommended to define these variables upfront, which makes the workflow configuration consistent and reusable across different bit-tasks
.
name: Test Bit Init
on:
workflow_dispatch:
jobs:
install:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_USER_NAME: ${{ secrets.GIT_USER_NAME }}
GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
BIT_CLOUD_ACCESS_TOKEN: ${{ secrets.BIT_CLOUD_ACCESS_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize Bit
uses: bit-tasks/init@v1
with:
ws-dir: '<WORKSPACE_DIR_PATH>'
Use the below step to resolve component packages from bit.cloud registry.
- name: Resolve component packages from bit.cloud registry (Mandatory for component installation using package managers other than Bit)
run: |
npm config set '@bit:registry' https://node-registry.bit.cloud
npm config set '@teambit:registry' https://node-registry.bit.cloud
npm config set //node-registry.bit.cloud/:_authToken ${{ env.BIT_CLOUD_ACCESS_TOKEN }}
Note: For external registries, append a new configuration to the registry config list and configure the authToken if required.
npm config set`@myorg:registry` https://<my-org-registry-url>
npm config set //<my-org-registry-url>/:_authToken ${{ <MY ORG ACCESS TOKEN> }}
Steps to create custom tasks in different CI/CD platforms.
Go to the GithHub action task directory and build using NCC compiler. For example;
npm install
npm run build
git commit -m "Update task"
git tag -a -m "action release" v1 --force
git push --follow-tags
For more information, refer to Create a javascript action