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 }}
2
Answers
This is the yaml file I've come up with. Note: Each run starts from the root folder. Note: to carry items to the next job you've to upload artifactsand download them in the next job.
The issue here is that both
build
,debug
andpublish
are run separately. That meansdist
directory created inbuild
step cannot be accessed bypublish
step directly.Looking at your workflow
yaml
file, I don’t see a need for separate steps. So you can merge all steps into a single step.On a side note:
github.events.inputs.*
toinputs.*
cd dist/
commandenv
key was formatted incorrectly before