Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish in custom artifactory #424

Open
gethari opened this issue Nov 19, 2024 · 2 comments · May be fixed by #425
Open

Publish in custom artifactory #424

gethari opened this issue Nov 19, 2024 · 2 comments · May be fixed by #425

Comments

@gethari
Copy link

gethari commented Nov 19, 2024

After spending lot of time, I looked into the code & found that, the regex pattern is always matching for only registries pointing to npm. In my case we have a custom artifactory the URL that looks like //art01.spotifycloud.io

action/src/index.ts

Lines 62 to 64 in 31ff97e

const authLine = userNpmrcContent.split("\n").find((line) => {
// check based on https://github.com/npm/cli/blob/8f8f71e4dd5ee66b3b17888faad5a7bf6c657eed/test/lib/adduser.js#L103-L105
return /^\s*\/\/registry\.npmjs\.org\/:[_-]authToken=/i.test(line);

Suggested solution

we can generalized the Regex and avoid hardcoding

const authLine = userNpmrcContent.split("\n").find((line) => {
  // Dynamically adapt to any registry by looking for :_authToken= pattern
  return /^\s*\/\/.*\/:[_-]authToken=/i.test(line);
});
gethari added a commit to gethari/action that referenced this issue Nov 19, 2024
@gethari gethari linked a pull request Nov 19, 2024 that will close this issue
gethari added a commit to gethari/action that referenced this issue Nov 19, 2024
@Andarist
Copy link
Member

Shouldn't it just work if you create .npmrc with a content like this?

//art01.spotifycloud.io/:_authToken=YOUR_TOKEN

I don't understand when the logic falls apart right now.

@gethari
Copy link
Author

gethari commented Nov 21, 2024

@Andarist , I already had created my .npmrc as you suggested, but the catch here I forgot to highlight is, I am using a Auth _auth variable & not _authToken & I think that is also one of the reason's the code is going into the else.. condition

I have updated my PR for this fix as well, thanks for the input 👍

gethari added a commit to gethari/action that referenced this issue Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants