4

How can I publish Npm Package to custom JFrog artifactory using Github action?

publish:
    name: Publish the Packages
    needs: build
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: ${{ env.NODE_VERSION }}
          registry-url: ${{ env.ARTIFACTORY_URL }}

      - name: Publish Packages
        run: npm publish
        working-directory: ${{ env.CORE_WORKING_DIR }}
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

The above one is giving 401 error. Is it the right approach to do or we've to use some third party actions?

TylerH
  • 20,799
  • 66
  • 75
  • 101
VJAI
  • 32,167
  • 23
  • 102
  • 164

1 Answers1

0

From what I can find, you'll have to do this in a more manual fashion by setting up the JFrog CLI in GitHub.

First, set up JFrog in GitHub actions: https://github.com/marketplace/actions/setup-jfrog-cli

Then, go to JFrog and find how to install npm packages to artifactory using their CLI: https://jfrog.com/blog/npm-flies-with-jfrog-cli/

- uses: jfrog/setup-jfrog-cli@v2
  env:
    # JFrog platform url (for example: https://acme.jfrog.io) 
    JF_URL: ${{ secrets.JF_URL }}
    
    # Basic authentication credentials
    JF_USER: ${{ secrets.JF_USER }}
    JF_PASSWORD: ${{ secrets.JF_PASSWORD }}
    or
    # JFrog Platform access token
    JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }}
- run: |
    jf rt npm-install --build-name=${{ inputs.build_name }} --build-number=${{ inputs.build_number }}

That's roughly how it should work.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Ian Mizer
  • 1
  • 1