https://www.offensive-security.com/metasploit-unleashed/writing-meterpreter-scripts/
Of course the above shows how to create the resource script needed so the last mile with plugging that into a git repo, cicd, is an exercise for the reader but try the following dockerfile as an example
From kali/kali:latest
ENV RHOST=target01.example.com
COPY metasploit.rc .
RUN metasploit -r metasploit.rc
I’d expect to see someone try this at March’s CTF Event