Simple, if you're deploying WSP solution packages. Then you can just create, deploy and activate a web application scoped feature using the feature.xml outlined below. Define your custom actions in the CustomActions.xml file.
<?xml version="1.0" encoding="utf-8"?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
Id="{5F377DB6-FDC8-477C-9423-4B16C5FAB505}"
Scope="WebApplication"
Version="1.0.0.0"
Title="Feature Title"
Description="Feature Description">
<ElementManifests>
<ElementManifest Location="CustomActions.xml" />
</ElementManifests>
</Feature>
Server side deployments are no longer recommended for new applications. Hence, you should also consider these options for deploying your custom actions:
- Create and deploy a SharePoint App that registers the custom actions. The app can be deployed to a site collection or globally through the App Catalog site.
- Use PowerShell scripting to deploy the custom action(s) to all applicable site collections. Leverage the Add-PnPCustomAction cmdlet from SharePoint Patterns and Practices (PnP).
The PnP PowerShell can run remote, works with SharePoint online and on-premises. I recommend this option the most.