Skip to content

vturb/bit-init-action

 
 

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.

Inputs

ws-dir

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

Example usage

  1. Create a new secret variable BIT_CONFIG_USER_TOKEN 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 also as an environment variable. Here, GITHUB_TOKEN secret is automatically created by GitHub Actions.
  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_CONFIG_USER_TOKEN: ${{ secrets.BIT_CONFIG_USER_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_CONFIG_USER_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

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 86.0%
  • JavaScript 11.6%
  • MDX 2.4%