Skip to content

Conversation

@akashdeep-singh-multani
Copy link
Contributor

@akashdeep-singh-multani akashdeep-singh-multani commented Jan 17, 2025

PR: CI/CD Deployment Workflow for @mindfiredigital/pivothead_core

Summary

This pull request introduces a CI/CD deployment workflow for the @mindfiredigital/pivothead_core project. The workflow automates the processes of building, testing, versioning, releasing, and deploying the package. It includes two main jobs: building the application and creating a GitHub release with automatic npm publishing. The workflow is triggered on pushes to the test-git-actions branch or can be manually triggered through the GitHub UI.

Workflow Overview

The workflow is defined in the .github/workflows/ci.yml file and consists of the following main steps:

1. Build Job

  • Checkout Repository: Pulls the latest code from the repository.
  • Set up Node.js: Configures the Node.js environment (version 20.x).
  • Install pnpm: Installs pnpm globally for managing dependencies.
  • Install Dependencies: Installs the necessary dependencies using pnpm.
  • Build Application: Runs the pnpm run build script to build the application.
  • Set Git User Information: Configures GitHub Actions with the appropriate Git user email and name for committing changes.

2. Create GitHub Release

  • Checkout Code: Ensures that the code is available for the release process.
  • Install pnpm and Dependencies: Reinstalls pnpm and dependencies.
  • Semantic Release & npm Publish: Runs npx semantic-release to automatically handle versioning, changelog generation, and npm package publishing.
  • Upload Build Artifact: Uploads the built artifacts (e.g., core/dist directory) as a GitHub artifact.

Workflow Configuration

The workflow is triggered by:

  • Push events to the test-git-actions branch.
  • Manual triggers via GitHub UI (workflow_dispatch).

Jobs Definition

name: Deployment Workflow

on:
  push:
    branches:
      - test-git-actions  # Trigger on push to 'test-git-actions' branch
  workflow_dispatch:  # Allow manual triggering of the workflow

jobs:
  build:
    name: "@mindfiredigital/pivothead_core"
    runs-on: ubuntu-latest  # Runs on Ubuntu latest image
    permissions:
      contents: write  # Allows modifying the contents (e.g., pushing commits)
      packages: read  # Grants read access to packages

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'

      - name: Install pnpm
        run: npm install -g pnpm  # Install pnpm globally

      - name: Install dependencies
        run: pnpm install  # Use pnpm to install dependencies

      - name: Build application
        run: pnpm run build  # Use pnpm to build the app

      - name: Set Git user name and email
        run: |
          git config --local user.email "[email protected]"
          git config --local user.name "GitHub Actions"

  create-github-release:
    name: Create GitHub release document and publish to npm
    runs-on: ubuntu-latest
    permissions:
      contents: write  # Allows modifying contents (e.g., creating releases)
    needs: build  # This job runs after the 'build' job

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20.x'

      - name: Install pnpm
        run: npm install -g pnpm

      - name: Install dependencies
        run: pnpm install

      - name: Semantic Release and npm release
        run: |
          npx semantic-release
        env:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Upload build artifact
        uses: actions/upload-artifact@v3
        with:
          name: core-build-zip
          path: ./packages/core/dist

@akashdeep-singh-multani akashdeep-singh-multani added the feature New feature or request label Jan 17, 2025
@akashdeep-singh-multani akashdeep-singh-multani merged commit acd9a0c into development Jan 17, 2025
2 checks passed
@akashdeep-singh-multani akashdeep-singh-multani linked an issue Jan 17, 2025 that may be closed by this pull request
sanghamitradash021 pushed a commit to sanghamitradash021/PivotHead that referenced this pull request Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add CI/CD workflows

2 participants