Accessing Codeberg repos from Google Cloud Build #990

Open
opened 2023-04-14 00:41:11 +02:00 by derat · 5 comments

Thanks for creating and maintaining Codeberg! I've been exploring the possibility of moving over some of my repositories from GitHub, but I've gotten stuck when trying to figure out how CI/CD will work.

I'm currently using Google Cloud Build to test and deploy my code. I'd like to explore moving away from GCP eventually, but in the short term, it'd be much easier if I could continue using my existing Cloud Build configs and triggers to build and deploy code from Codeberg-hosted repositories.

I haven't found any way to do this yet, though. I was thinking I could use webhooks to trigger builds in response to commits (apparently supported by Cloud Build), but I'm not sure how to convince Cloud Build to fetch the code from Codeberg in the first place. Per Google's Cloud Build repositories page, it seems like only GitHub, GitLab, and Bitbucket are supported, and the UX seems to confirm this.

It sounds like there's another GCP thing called Cloud Source Repositories. I was hopeful that I could mirror Codeberg repositories to Cloud Source Repositories and then build from CSR, but per the docs:

Only Bitbucket Cloud and GitHub Cloud repositories can be mirrorred to Cloud Source Repositories; self-hosted Bitbucket and GitHub mirroring are not supported.

I haven't explored whether there's some way to manually sync a Codeberg repository to CSR periodically.

I suspect that this is just a GCP shortcoming, but I figured I'd create an issue since I couldn't find any existing discussion online.

Thanks for creating and maintaining Codeberg! I've been exploring the possibility of moving over some of my repositories from GitHub, but I've gotten stuck when trying to figure out how CI/CD will work. I'm currently using [Google Cloud Build](https://cloud.google.com/build) to test and deploy my code. I'd like to explore moving away from GCP eventually, but in the short term, it'd be much easier if I could continue using my existing Cloud Build configs and triggers to build and deploy code from Codeberg-hosted repositories. I haven't found any way to do this yet, though. I was thinking I could use webhooks to trigger builds in response to commits (apparently [supported by Cloud Build](https://cloud.google.com/build/docs/automate-builds-webhook-events)), but I'm not sure how to convince Cloud Build to fetch the code from Codeberg in the first place. Per Google's [Cloud Build repositories](https://cloud.google.com/build/docs/repositories) page, it seems like only GitHub, GitLab, and Bitbucket are supported, and the UX seems to confirm this. It sounds like there's another GCP thing called [Cloud Source Repositories](https://cloud.google.com/source-repositories). I was hopeful that I could mirror Codeberg repositories to Cloud Source Repositories and then build from CSR, but [per the docs](https://cloud.google.com/source-repositories/docs/mirroring-a-github-repository): > Only Bitbucket Cloud and GitHub Cloud repositories can be mirrorred to Cloud Source Repositories; self-hosted Bitbucket and GitHub mirroring are not supported. I haven't explored whether there's some way to manually sync a Codeberg repository to CSR periodically. I suspect that this is just a GCP shortcoming, but I figured I'd create an issue since I couldn't find any existing discussion online.
Author

I managed to create a convoluted/awful/shameful system to get code from Codeberg to Cloud Build by way of Cloud Source Repositories. I created a Cloud Function that's triggered by a Gitea webhook to clone a repo from Codeberg and then run git push --mirror to shove the code into a CSR repo (Google makes the auth at this step super-painful). Then the Cloud Build trigger sees the change in the CSR repo and kicks off a new build. I don't know if this will be useful to anyone else, but I can try to clean up the code if there's any interest.

I managed to create a convoluted/awful/shameful system to get code from Codeberg to Cloud Build by way of Cloud Source Repositories. I created a [Cloud Function](https://cloud.google.com/functions) that's triggered by a Gitea webhook to clone a repo from Codeberg and then run `git push --mirror` to shove the code into a CSR repo (Google makes the auth at this step super-painful). Then the Cloud Build trigger sees the change in the CSR repo and kicks off a new build. I don't know if this will be useful to anyone else, but I can try to clean up the code if there's any interest.
Author

My code and some instructions are at https://codeberg.org/derat/cloud-source-mirror, in case they help anyone.

My code and some instructions are at https://codeberg.org/derat/cloud-source-mirror, in case they help anyone.
Author

Just as an update, Cloud Source Repositories seems like it's unavailable to new customers as of 2024-06-17 (official messaging, Reddit discussion), so the webhook workaround that I described above may no longer be an option.

Just as an update, Cloud Source Repositories seems like it's unavailable to new customers as of 2024-06-17 ([official messaging](https://cloud.google.com/source-repositories/docs), [Reddit discussion](https://www.reddit.com/r/googlecloud/comments/1d189h4/cloud_source_repo_shutting_down/)), so the webhook workaround that I described above may no longer be an option.
Owner

Thanks for the update, and I guess sorry for the radio silence since... Is this something that is still actionable on the Codeberg / Forgejo end? @derat

Thanks for the update, and I guess sorry for the radio silence since... Is this something that is still actionable on the Codeberg / Forgejo end? @derat
Author

@n0toose: I think that there's sadly nothing that Codeberg can do about this (maybe short of emulating whatever protocols are used for Cloud Build's existing GitHub Enterprise or GitLab Enterprise Edition support, but I have no idea what that would involve or if it's even possible).

I filed https://issuetracker.google.com/issues/354234739 requesting that Cloud Build support either Codeberg or arbitrary public git repositories, but I won't hold my breath waiting for that to happen.

Please feel free to close this issue if this tracker should only be used for things that can be addressed by Codeberg. :-)

@n0toose: I think that there's sadly nothing that Codeberg can do about this (maybe short of emulating whatever protocols are used for Cloud Build's existing GitHub Enterprise or GitLab Enterprise Edition support, but I have no idea what that would involve or if it's even possible). I filed <https://issuetracker.google.com/issues/354234739> requesting that Cloud Build support either Codeberg or arbitrary public git repositories, but I won't hold my breath waiting for that to happen. Please feel free to close this issue if this tracker should only be used for things that can be addressed by Codeberg. :-)
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Codeberg/Community#990
No description provided.