Skip to content
forked from bit-tasks/init

Initialize Bit task for CI/CD

Notifications You must be signed in to change notification settings

Eventiva/bit-init

 
 

Repository files navigation

Initialize Bit for CI/CD Pipelines

Initialize Bit for CI/CD Pipelines

GitHub Actions

This task installs Bit in your CI by executing bit install inside the workspace directory. It uses Node 18.

Inputs

ws-dir

Optional The workspace directory path from the root. Default "./".

Example usage

  1. Create a new secret variable for BIT_CLOUD_ACCESS_TOKEN(docs) and use it as an environment variable in your GitHub Action.
  2. [Optional] Create new secret variables GIT_USER_NAME, GIT_USER_EMAIL and use them as environment variables in your GitHub Action.
  3. [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.
  4. [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>'

Resolve component packages

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> }}

Contributor Guide

Steps to create custom tasks in different CI/CD platforms.

GitHub Actions

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

About

Initialize Bit task for CI/CD

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

  •  
  •  

Packages

No packages published

Languages

  • TypeScript 86.1%
  • JavaScript 11.5%
  • MDX 2.4%