dokku/github-action

Deploying to a branch besides master

Closed this issue · 2 comments

Description of problem

Deploying from a branch other than master does not work

How reproducible

Use the example action file provided for deploying from a branch other than master

Steps to reproduce

  1. Create action runner based on example
  2. Push to target branch

Actual Results

Pushing to Dokku Host
remote: -----> WARNING: deploy did not complete, you must push to main.        
remote: -----> for example, try 'git push <dokku> staging:main'

Expected Results

For it to deploy

Environment Information

N/A

How (deb/make) and where (AWS, VirtualBox, physical, etc.) was Dokku installed?:

Followed install instructions on website, running on AWS EC2

Additional information

The following script works as intended

name: Staging Deployment

on:
  push:
    branches:
      - 'staging'

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout repository
      uses: actions/checkout@v3
      with:
        fetch-depth: 0

    - name: Set up SSH key
      uses: webfactory/ssh-agent@v0.5.3
      with:
        ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

    - name: Add Dokku server to known_hosts
      run: |
        mkdir -p ~/.ssh
        ssh-keyscan -H dokku.me >> ~/.ssh/known_hosts

    - name: Set new upstream git remote
      run: git remote add dokku-staging ssh://dokku@dokku.me:22/staging-backend

    - name: Force push to Dokku staging
      run: git push --force dokku-staging staging:main

Related to #16, just wanted to share this in case it helped other people.

@neverabsolute Did you try using branch parameter in your configuration?
https://github.com/dokku/github-action/blob/master/README.md#inputs

      - name: Push to dokku
        uses: dokku/github-action@master
        with:
          git_remote_url: ssh://dokku@${{ vars.DOKKU_SERVER_IP }}:22/{{ vars.DOKKU_APP_NAME }}
          ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
          branch: staging

Yeah that method of specifying a branch is what you want. You can set it to main if thats the branch you push to.