SimonScholz / google-chat-action

GitHub Action to send notifications to a google chat using the cards v2 syntax
Apache License 2.0
16 stars 5 forks source link

[Feature] Ability to specify base URL for links #111

Open rosmko opened 6 months ago

rosmko commented 6 months ago

Hi, thanks for the great action. We were able to use it for our CI pipeline but we are not hosting our repository on GitHub, rather on a self hosted Forgejo/Gitea instance, so the links on the default section do not work as they seem to be hard coded to github.com. Luckily, Forgejo and Gitea URL's seem to be compatible with GitHub so changing the URL base would fix the issue, f.ex https://github.com/my-org/my-repo/actions/runs/31 -> https://git.example.com/my-org/my-repo/actions/runs/31.

Would it be possible to add a setting for this functionality in this action? I assume self-hosted GitHub enterprise users would benefit from this as well.

SimonScholz commented 5 months ago

Hi @rosmko

Thanks for sharing this circumstance with me. For sure I can make this customizable.

SimonScholz commented 5 months ago

Hey @rosmko

Can you please confirm that the path in the urls are matching for each case:

If that´s not the case be might want to customize this even further, since the path scheme could be totally different for other systems.

For now, you could also use the additionalSections input and set the createDefaultSection input to false. And then inside the additionalSections specify whatever you need.

rosmko commented 5 months ago

Anonymized URLs from our organization

https://git.example.com/my-org/my-repo/commit/<commit-hash>
https://git.example.com/my-org/my-repo/actions/runs/50
https://git.example.com/my-org/my-repo/pulls/639

Looks like the only difference is the pull reguest URL for us is plural pulls, on GitHub a single PR link is just /pull/. Our current needs don't require the pull request link so this is not a big issue. Although perhaps we could make it an optional setting, f.ex. prPath with a fallback to GitHub standard?

rosmko commented 5 months ago

Also, I'm aware of the additionalSections but I couldn't wrap my head around how to configure it, so we stuck to the default section :slightly_smiling_face:

SimonScholz commented 4 months ago

Hey @rosmko ,

I am still wondering whether just changing the base URL would do the trick for you. Unfortunately I am not familiar with Forgejo and Gitea, but my GitHub-Action relies on https://www.npmjs.com/package/@actions/github in order to read the commit hash and run id etc from the @actions/github package. Not sure if the Forgejo and Gitea actions are compatible with the @actions/github package. Maybe we could even have a call where you could show me how Forgejo and Gitea work in order to find the best solution for your special case. Don´t get me wrong, making the base URL configurable would be easy, but I am aiming for a solid solution, which won´t clutter this action with too many configuration settings, which might not be needed.