actions / setup-dotnet

Set up your GitHub Actions workflow with a specific version of the .NET core sdk
MIT License
922 stars 454 forks source link

GitHub Actions to push to Azure Artifacts: Unable to load the service index for source ' 'Response status code does not indicate success: 401 (Unauthorized) #370

Closed benyusouf closed 1 year ago

benyusouf commented 1 year ago

Description: I wanted to create a Github workflow that push feed to Azure Artifacts. I carefully followed the article here and the tutorial here. However, I keep getting this error

error: Unable to load the service index for source https://pkgs.dev.azure.com/<org>/<proj>/_packaging/<proj>/nuget/v3/index.json. error: Response status code does not indicate success: 401 (Unauthorized).

I created a PAT for all accessible organizations, granted it full access and added it in my Github Action secrets just as the docs says but the error persists. Does anyone have idea what could be wrong here?

Task version: I was using v1 but also changed to v3 but the error still occur.

Expected behavior: Expecting feed to be published to Azure Artifacts

Actual behavior: Build stopped and failed

marko-zivic-93 commented 1 year ago

Hello @benyusouf Thank you for feedback. We will investigate this issue and come back to you as soon as we have some information 🙂

benyusouf commented 1 year ago

Hello @benyusouf Thank you for feedback. We will investigate this issue and come back to you as soon as we have some information 🙂

Thank you @marko-zivic-93 , I'd wait for your findings

panticmilos commented 1 year ago

hi @benyusouf, could you provide us public repo or a mock of the private repo? Or it's identical to the workflow you have posted?

benyusouf commented 1 year ago

hi @benyusouf, could you provide us public repo or a mock of the private repo? Or it's identical to the workflow you have posted?

Yes it's, attached file is what my workflow looks like. I have my secret saved as AZURE_DEVOPS_TOKEN az-feed.zip

benyusouf commented 1 year ago

image Hi @marko-zivic-93 @panticmilos please any update on this? I change to Github package registry, and using Github PAT with package registry scope but still getting 401 error, it seems the workflow is not adding the API key or something.

panticmilos commented 1 year ago

hi @benyusouf, thank you for your patience, I was not able to reproduce the issue, but I will give it another shot and get back to you soon :)

benyusouf commented 1 year ago

Hi @panticmilos thank you for your response, I was able to resolve by adding --api-key ${{ secrets.GITHUB_TOKEN }} to dotnet nuget push command. My resulting command looks like:

- name: 'dotnet publish' run: dotnet nuget push bin/Release/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }}

This works for both Azure Artifact and Github Registry, so like I mentioned, it seems that the action is really passing the token.

panticmilos commented 1 year ago

hi @benyusouf, in this case, I will close this issue. If you have any additional questions feel free to continue conversation here.

BenjaminMichaelis commented 1 year ago

I was having this issue as well, and passing the ${{ secrets.GITHUB_TOKEN }} did not seem to solve it. This seems like an issue since it breaks when following the documentation and since it seems like authorization isn't working properly to the artifacts feed.

mhascak commented 1 year ago

I have tha same issue ${{ secrets.GITHUB_TOKEN }} did not helped.