Github actions for creating an npm pacakge from angular workspace/library

Discussão em 'Angular' iniciado por Hamza Abbas, Março 31, 2025.

  1. Hamza Abbas

    Hamza Abbas Guest

    [​IMG]So I have this github action code, I'm trying to create a github package for diferent libraries in the workspace, The build step works fine however on the publish step I get this error Error: Process completed with exit code 2. dist folder doesnt exist it says. Note the dist folder is created after the build process is completed and it is added .gitignore fire as well.

    I don't understand what am I doing wrong here.


    name: Angular Package

    on:
    release:
    types: [created]
    workflow_dispatch:
    inputs:
    release_type:
    required: false
    type: string
    project_name:
    description: 'Enter the project name'
    required: true
    type: string

    jobs:
    build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: actions/setup-node@v3
    with:
    node-version: 16

    - name: Install Angular CLI
    run: npm install -g @angular/cli

    - name: Install dependencies
    run: npm ci

    - name: Build Angular Project
    run: ng build ${{ github.event.inputs.project_name }}


    debug:
    needs: build
    runs-on: ubuntu-latest
    steps:
    - name: List Files in dist
    run: ls -R dist

    - name: Print Current Directory
    run: pwd

    publish:
    needs: build
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
    uses: actions/checkout@v2

    - name: Set up Node.js
    uses: actions/setup-node@v2
    with:
    node-version: 16

    - name: Publish to GitHub Packages
    run: |
    cd dist/${{ github.event.inputs.project_name }}
    npm config set //npm.pkg.github.com/:_authToken ${{ secrets.GITHUB_TOKEN }}
    npm publish --access public
    env:
    NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    Continue reading...

Compartilhe esta Página