If mirror is meant to trigger CI on sync do not select mirror option when prompted for repo type, instead select:
Run CI/CD for external repository
Poke Sync command
curl -s --request POST \
--header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
"https://${GITLAB_HOST}/api/v4/projects/PROJECT_ID/mirror/pull"
Can find project id at: -- Settings → General → General project settings
If you destroy commit history then your changes will not be synced. The solution is to delete the branch in the Mirror. Don't ever destroy commit history on main branch.
Check sync status
curl -s --fail-with-body \
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
"https://${GITLAB_HOST}/api/v4/projects/PROJECT_ID" |
jq '{
mirror,
mirror_trigger_builds,
mirror_user_id,
only_mirror_protected_branches,
mirror_overwrites_diverged_branches
}'
If mirror_trigger_builds is false then fix it:
curl -s --fail-with-body --request PUT \
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
--data-urlencode "mirror=true" \
--data-urlencode "mirror_trigger_builds=true" \
"https://${GITLAB_HOST}/api/v4/projects/PROJECT_ID" |
jq '{mirror, mirror_trigger_builds, mirror_user_id}'