Automating mergeback step (gitflow)

When using a gitflow style workflow, I’d like to automate the mergeback step of, e.g., main into staging after a release / tag are cut.

Assuming I have a github token as GITHUB_TOKEN, any simple examples of automating a merge back or similar operation/

I’ve seen some github actions that do this (in node), and at my last company, we had a node based program that did this, but is there a way to do this with vanilla git? I tried using hub, but even with git config --global hub.protocol https, it still seems to use ssh by default. I’d just as soon use the token auth vs. upgrading the Circle SSH user to read/write level access (and in this case, I think I need a user with admin privs)

I think if I mangle the project / global git configs sufficiently, I can get this to work?

currently, trying to run something like

      description: Merge back default (shared) branch into trunk
      command: >
        hub diff -s --exit-code origin/<< parameters.trunk-branch >> origin/<< parameters.default-branch >> 
        || ( hub merge origin/<< parameters.trunk-branch >> origin/<< parameters.default-branch >> 
        && hub push origin << parameters.default-branch >>)

Ended up doing it this way:

  - run:
      name: Merge back default (shared) branch into trunk
      command: |
        git config --global user.name "xyz"
        git config --global user.email "foo@example.com"
        git remote set-url origin $(git remote get-url origin | sed -e "s#:#/#" -e "s#^git@#https://$GITHUB_TOKEN@#g")
        git checkout << parameters.default-branch >>