How do I get bitrise to commit and push to github after build

I wasnt show how to do this so I added a script to the workflow with the github commands:

  • git checkout -b branchname
  • git add .
  • git commit -m “message”
  • git push origin branchname

but it doesnt push.

git_test:
    description: "distribute app"
    steps:
    - activate-ssh-key@4:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@6: {}
    - script@1:
        inputs:
        - content: |-
            #!/usr/bin/env bash
            # fail if any commands fails
            set -e
            # debug log
            set -x

            # write your script here
            echo "Hello World!"
            pwd
            cd $BITRISE_SOURCE_DIR
            git checkout -b deployer
            echo "testing" >> man.txt

            git branch
    - script@1:
        inputs:
        - content: |-
            #!/usr/bin/env bash
            # fail if any commands fails
            set -e
            # debug log
            set -x

            # write your script here
            echo "Hello World!"

            git checkout deployer
            git add .
            git commit -m "working"
            git push origin deployer

            curl \
              -X POST \
              -H "Accept: application/vnd.github.v3+json" \
              -H "Authorization: token ghp_******" \
              -d "{\"head\":\"deployer\",\"base\":\"main\",\"body\":\"deployed\"}" \
                https://api.github.com/repos/<username>/testing/pulls

Any help would be appreciated

If only things were that simple:

If it’s not too late, this is the approach I took:

In my situation, I wanted to set the versionCode and versionName

  1. I modified one of my custom scripts to perform the following:
    git config --global user.email "myUser@myDomain.com" git config --global user.name "My User Name" git add --all git status git commit -m "Bitrise Commit: Some Description" git push

More information on changing the GIT configuration can be found here.

The other step is very important. I assume here that your repository resides on Github.

You must track down the SSH key first on the Bitrise Project. I went to the Settings:


then I showed and copied the SSH key found in the settings:

I added that SSH key as a deploy key to the Github repository of interest. Go to Github and select Settings:

Then Find the Deploy Keys option:


You will want to add a new SSH Key. Paste the SSH key found in your Bitrise project into that entry. Make Damn Sure that Write Access has been granted and save it.

You should be all set to go. I hope this helps.

2 Likes