go-semantic-release / semantic-release

📦🚀 semantic-release written in Go
https://go-semantic-release.xyz
MIT License
395 stars 43 forks source link

GitLab no longer supports pull mirroring #150

Closed christophwitzko closed 1 year ago

christophwitzko commented 1 year ago

Until recently, we used https://gitlab.com/go-semantic-release/semantic-release as a mirror for the semantic-release project to test the GitLab integration. On 13-09-2022, GitLab moved this functionality to the Premium tier, and therefore, we need another solution to test our integration. (see https://docs.gitlab.com/ee/user/project/repository/mirror/pull.html)

superewald commented 1 year ago

Not entirely sure about this but it would be my approach (untested as of now):

  1. create a ci job in gitlab which simply pushes all tags and branches from github to gitlab ("raw mirroring") and is only executed on pipeline triggers:
    # gitlab ci job which mirrors the repository on github webhook event
    mirror_repository:
    only:
    - triggers # only run this job on pipeline triggers
    # can add additional rules to check for a specific variable set from pipeline trigger webhook
    before_script:
    # setup ssh/git to be able to push to this repository
    script:
    - git clone https://github.com/go-semantic-release/semantic-release gh-mirror
    - cd gh-mirror
    - git remote remove origin
    - git remote add origin https://gitlab.com/go-semantic-release/semantic-release
    - git push --prune --all
    - git push --prune --tags
  2. create a GitLab Pipeline Trigger in the gitlab project
  3. create a GitHub Webhook for push/merge events which calls the Pipeline Trigger above

I never used GitHub Webhooks so I'm not sure about the last step but from what I read it should work. Got the basic idea from a medium article

superewald commented 1 year ago

I did a simple PoC repository which shows the workflow is working:

Using pipeline trigger variables and the webhook this can be customized to your desire. If you need help setting this up or have any questions feel free to ask.

christophwitzko commented 1 year ago

Hey @superewald, thank you so much for looking into this. 👍 I think I will add a push-based approach to GitHub Actions because GitHub is the main development platform.