
I’ve done exactly this before. It looks like this.
#lang racket ;; github/action
(require "define-github-action.rkt")
(github-action
(name "push")
(on
(push
(branches [ "master" ]))
(pull_request
(branches [ "master" ])))
(jobs
(build
(runs-on "ubuntu-latest")
(steps
(uses "actions/checkout@v1")
#;
(uses "actions/cache@v2"
#:name "Cache racket packages"
#:with ((path "~/.racket")
(key "racket-packages")
(restore-keys "racket-packages")))
(uses "Bogdanp/setup-racket@v0.10"
#:name "Setup Racket environment"
#:with ([distribution "minimal"]
[version "7.8"]))
(run "racket build.rkt image")
(run
#:name "Push to Heroku Container Registry"
#:env ([HEROKU_API_KEY "${{ secrets.HEROKU_API_KEY }}"])
"heroku container:login"
"docker build -t ..."
"docker push ...")
(run
#:name "Release"
#:env ([HEROKU_API_KEY "${{ secrets.HEROKU_API_KEY }}"])
"heroku container:release -a ... web")))))

The generated yaml isn’t very pretty. I also didn’t abstract anything. I just did it for fun (and because I hate editing yaml).

I’m not sure the approach could be extended to do what you want, but here is a gist with the relevant module https://gist.github.com/aymanosman/6a4a9f97ace1859ec1a62cf3c6adddef