There are various ways you can automate ZAP:
Quick Start command line - quick and easy, but only suitable for simple scans
Docker Packaged Scans - the easiest way to get started with ZAP automation with lots of flexibility
GitHub Actions - the associated packaged scans available on the GitHub Marketplace
Automation Framework - a new framework which is not tied to any container technology and will in time replace the Command Line and Packaged Scan options
API and Daemon mode - for full control over ZAP via a comprehensive API