YunaBraska / github-workflow-plugin

Your Ultimate Wingman for GitHub Workflows and Actions! 🚀
https://github.com/YunaBraska/github-workflow-plugin
Apache License 2.0
44 stars 10 forks source link

Does not recognize GitHub Enterprise internal actions #52

Open holomekc opened 8 months ago

holomekc commented 8 months ago

First of all thank you so much for the awesome work!!!

What happened? When using in GitHub enterprise the actions from our organization are not recognized, although GitHub Enterprise is successfully integrated into IntelliJ (Create new projects via VC works fine). When I checked the logs I could see that github itself was contacted, but not the Enterprise server. So it seems that this is currently not supported :(. As far as I am aware the structure of defining the usage of an action is still: {org}/{repo}/{action}@{ref} . Even if it is an enterprise action. There seems to be no prefix to indicate that it is an internal action.

How can we reproduce the issue? Steps to reproduce the behavior: This is difficult to describe. The GitHub config in IntelliJ uses an Enterprise integration and token and you need an action, which is specified in the workflow just by GitHub Enterprise org and repo.

Relevant log output com.github.yunabraska.githubworkflow.helper.GitHubWorkflowHelper - Download [https://raw.githubusercontent.com// ... But as said the action does not exist in GitHub itself.

Operating System OSX

Plugin Version 3.2.1

IDE Name and Version IntelliJ IDEA 2023.3.2 (Ultimate Edition)

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

YunaBraska commented 8 months ago

@holomekc thank you for your kind words. And also thank you for reporting this behavior. 🙃

I am currently refactoring a lot and the GitHub integration is my next step. Just as an idea... Since I have no enterprise account to test with, maybe you can tell me the different call I need to make and how to tell if its enterprise action.

holomekc commented 8 months ago

Hi @YunaBraska,

Thx for the quick answer. I am afraid you cannot really see it. The pattern is always:

{owner}/{repo}@{ref}

See: https://docs.github.com/en/enterprise-server@3.11/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsuses

So there is no difference. In my initial question I wrote nonsense... so it might look like this: actions/checkout@v4 Or top/secret@v1

So there is no indicator. I guess what you could do, is to check if an Enterprise GitHub account is registered in the Settings of IntelliJ and then try to resolve the action first via GitHub Enterprise and then GitHub.

This is really a little bit annoying and probably not efficient, but I see no other way. I checked the logs during job setup and I can see something like this:

https://api.github.com/repos/Azure/setup-kubectl/tarball/{hash}

Or

https://{ghe-host}/api/v3/repos/actions/checkout/tarball/{hash}

As you can see we have the second action "cashed" in our org.

The logs do not say which approach it uses to decide which server to contact though.

YunaBraska commented 8 months ago

Hi @holomekc I am reading many GitHub documentations, but missing the big picture somehow. When I would try to resolve top/secret@v1... 1) how do I know which server to use for the API call? Is this a repository URL? 2) How do I know if your account is an enterprise account?

holomekc commented 8 months ago

Hi @YunaBraska , top = owner secret = repository

that is all info you have actually. At least from the workflow file. If I find the time I can check the IntelliJ Settings api. My only idea was to check the settings for multiple GitHub entries and then prio GHE > GH.

Br, Chris

BelmoMusta commented 8 months ago

Hello @holomekc I myself use an organization account that is integrated into Intellij. I can fetch the referenced internal actions successfully.

Is there an error log when trying to fetch your organization internal actions ?

holomekc commented 8 months ago

No error. I just see in the logs that the plugin tries to contact github.com. As far as I could see it the plugin has the github.com urls hardcoded.

YunaBraska commented 8 months ago

The Plugin has hardcoded GitHub.com URLs. @holomekc is using cache/self-hosted actions as far as I understand. If this is true, I would need to get to know somehow the URL http://some-url.com/top/secret. So I currently try to find how to get this URL. Via Postman, I even fail to list the organisations of a user, but I only get an empty array back. The user itself doesn't seem to have a flag called "enterprise"

holomekc commented 7 months ago

Hi @YunaBraska,

I did some tests. I checked out your code and changed the hardcoded section first with the urls of our enterprise server. After some adjustments it worked fine. There are some things I noticed:

I noticed that you handle the download in the FileDownloader class. As it seems you already stream the configured GitHub accounts. I think here you could do some tricks to figure out that there is an enterprise server: account.getServer().isGithubDotCom() returns false in this case. Maybe sort them like this? GHE > GH. This would also solve the cached action topic. Furthermore, account.getSever().getHost() provides you ... well ... the host. Nevertheless, this is not the raw content endpoint you want to access. In our case it would be enough to add raw. as a prefix. I tried to find something related to that structure in the GitHub enterprise documentation, but no luck so far. So I am not 100% sure if the format is always:

raw.<host>

Maybe as an idea, you could think about moving the decision of using the github.com url also to the FileDownloader, when you have the accounts available. Then you can decide, which host to use. You need to recognize, when the raw endpoint should be used though. Sadly for GitHub.com the raw url is different to the host, so this would require some special handling.

Additionally, it is a little bit annoying, that you would need to do 2 requests per server due to the yml, yaml topic, but I noticed, that you check for yaml as well in other cases, so I think this should be included as well.

Does this help already, or do you need further information?

Br, Chris

YunaBraska commented 7 months ago

Hi Chris, thanks for your awesome research. And yes, that probably helps me a lot! action.yml: you are right, it makes sense to check for yaml and yml whitespaces: you are right, the resolve action is still in an early phase and need more handling. cache: Everything gets registered in the cache, but there is a cleaned up afterwards. I use the cache to synchronise the actions and their user settings between multiple projects and files. Everything unresolved without a user setting will be cleaned up later.

account.getServer().isGithubDotCom() and then get the URL from account.getSever().getHost() sounds promising... My only concern is, that I can't test these things.

Project Status:

holomekc commented 7 months ago

Hi @YunaBraska, thanks for the quick answer. I am happy that it helps.

Regarding recruiting. Normally my answer would be yes, but I am working too much already. I should do more for myself, I just work from morning till evening. But this is a different story. What I can do for sure is to help test some stuff. Or do some adjustments. I am not sure. The topic regarding Jetbrains and GitHub action support is questionable. I dont want to stress you with a topic, which is then solved by Jetbrains. I saw, that you wrote at the EAP page. I could not find any details regarding this feature yet. I searched here.

Br, Chris

YunaBraska commented 7 months ago

JB has a ticket here: https://youtrack.jetbrains.com/issue/IDEA-345340/Improve-Github-Actions-development-UX-in-IDE I also have other projects ongoing. Unfortunately, this project is my weakest one as it is really time-consuming. Even I can answer you quickly, don't expect big or fast implementations ;) But your research is really powerful, I will have a look into it.

YunaBraska commented 5 months ago

Due to significant changes introduced by JetBrains, my plugin now faces numerous disruptions. After dedicating substantial effort to this project last year, I find myself needing assistance to move forward. If you're interested in contributing or know someone who might be, please feel free to get involved. I am available to provide guidance through the intricacies of the plugin.