Set the "file" column as empty and the "value" column to the URL of whatever you're trying to link to. The CB Gallery auto action can already handle creating new linked gallery entries. If you insist on doing this with a Code action then you should build a media item object to work with. Example as follows.
Code:
$media = new \CB\Plugin\Gallery\Table\ItemTable()
$media->set( 'user_id', USER_ID_THIS_BELONGS_TO_HERE ); // e.g.42, 38, 91
$media->set( 'asset', 'ASSET_THIS_MEDIA_BELONGS_TO_HERE' ); // e.g. profile.42, cbgroupjive.group.4, article.3, etc..
$media->set( 'type', 'MEDIA_TYPE_HERE' ); // stricly one of the following: photos, videos, files, music
$media->set( 'value', 'URL_OF_MEDIA_HERE' ); // e.g. http://www.example.com/my_photo.jpg
$media->set( 'published', 1 );
$media->store(); // saves all of the above to the database