Add CI/CD for GitHub to registration features
What does this MR do and why?
We want to add CI/CD for GitHub to Registration features available to users who have service ping data sharing enabled.
Screenshots or screen recordings
Before | After |
---|---|
How to set up and validate locally
Requirements
- Make sure you have gitlab runner installed.
- Make sure you have instance or project runner to process pipelines. Instance runner can be created the same way as project runner but from
Admin Area -> CI/CD -> Runners
(/admin/runners
). - Make sure you have some env accessible from the internet otherwise GitHub won't be able to access your dev env to trigger webhook endpoint. You may use something like ngrok(if allowed to use on dev env), I used my personal web server to proxy requests to local dev env. Please setup this before verification.
- You must use some domain name(not
localhost
) for you dev env otherwise it will not create webhook on GitHub side forlocalhost
or127.0.0.1
address:
config/gitalb.yml
production: &base
#
# 1. GitLab app settings
# ==========================
## GitLab settings
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
host: test.example.com
port: 3000
https: false
config/environments/development.rb
Rails.application.configure do
config.hosts << "test.example.com"
# ...
end
Steps
- Testing previous behavior:
- Make sure you're on a Premium plan GitLab GDK instance
- Enable GitHub integration:
- Follow documentation steps to create CI/CD for GitHub. Below are the same steps with some tips to verify it.
- Create new GitHub project with
README.md
file and.gitlab-ci.yml
:
stages:
- build
- test
job_build:
stage: build
script:
- echo "Building the project"
job_test:
stage: test
script:
- echo "Running tests"
- In GitHub, create a token https://github.com/settings/tokens/new with
repo
andadmin:repo_hook
scopes - In GitLab, create a new project:
- On new project page select Run CI/CD for external repository.
- Click on GitHub button.
- For Personal access token, paste the token.
- Select List Repositories.
- Select Connect to select the repository.
- Verify you have new Webhook on GitHub side:
- Verify you have new GitHub integration on GitLab side for this new project:
- Verify you have new mirroring on GitLab side for this new project:
- Create new branch on GitHub side
- Modify
README.md
file inside this new branch and create new PR. - Verify project pipelines on GitLab side.
- Verify webhook status on GitHub side (
Settings -> Webhooks -> Select webhook -> Recent Deliveries
). - Verify PR status.
- When registration features are enabled:
- Make sure you're on a free plan GitLab GDK instance (for example, remove current license or stub #current to return
nil
) - Make sure you have the Registration Features checkbox enabled (
Admin -> Settings -> Metrics and profiling -> Usage statistics -> Enable Service Ping & Enable Registration Features
) - Follow steps from 1. to verify it.
- Make sure you're on a free plan GitLab GDK instance (for example, remove current license or stub #current to return
- When registration features are disabled:
- Make sure you're on a free plan GitLab GDK instance
- Make sure you have the registration features checkbox disabled (
Admin -> Settings -> Metrics and profiling -> Usage statistics -> Enable Registration Features
) - Verify you don't have Run CI/CD for external repository on new project page.
- Make sure that the new text appears on the docs page:
- run
gdk restart gitlab-docs
- go to
<local_gitlab_docs_host>/ee/user/admin_area/settings/usage_statistics.html#registration-features-program
and make sure the new section is on the page and the link works
- run
Updated doc | Link page |
---|---|
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #422285 (closed)
Edited by Taras Tadai