Branch push triggers don't seem to be working for orphan branches?

If I have a workflow defined like so:

on:
  push:
    branches:
      - '*'

Any normal branches created with

git checkout -b branch-name

and pushed to the repository trigger the workflow as expected.

However, if I create an orphan branch and push that to the repository, the workflow does not run and will not run for any subsequent commits pushed to that branch. Is this expected behaviour?

Just to be very clear about what you mean when you say an “orphan branch”, you mean one that has a new root commit and doesn’t share history with other branches?  (ie, one created via git checkout --orphan)  That shouldn’t affect the behavior of GitHub Actions.

What will is if that new branch doesn’t have workflows in it.  If you push up a new branch with no workflows, none will execute.  (The workflow won’t be read from the master branch, but from the branch you’re pushing to.)  This means that you can functionally isolate this new branch from (say) your master branch’s workflows by checking in unique workflows.  So you could have unique workflows for your typical branches and your gh-pages branch, for example.

Not sure if I’ve get it. Do I have to workflows in the branch I’m acting on?

I’m not getting any success on this https://github.com/youthradio/mh-supportingfriends/blob/master/.github/workflows/main.yml workflow, where I want to trigger some deployment when push to gh-pages branches. However gh-pages branch is an empty tree with only static code, no github actions there. The workflow works on I use **on [push] **and push to master that has github/workflow.

Do I need an workflow inside the branch I want to trigger the event?  thanks

Yes, in this case you need a workflow file in the branch that you’re trying to run triggers on.

1 Like

Here is my workflow,

I’ve tried different branches and it doesn’t trigger.

The only success I’ve had was using the general form on: [push]

name: deploy on server
on:
  push:
    branches:
      - 'gh-pages'
jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
    - name: multiple command
      uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.HOST }}
        username: ${{ secrets.USERNAME }}
        key: ${{ secrets.key }}
        port: ${{ secrets.PORT }}
        script: |
          whoami
          ls -al

Now evertyhing makes sense! 

thanks I’ll try to keep the branch with the workflow.

Still no sucess, even though I’m pushing to a branch with github workflow, target to push branch !master

do you have any tips?

thanks

on:
  push:
    branches:
      - '!master'

https://github.com/youthradio/mh-supportingfriends/blob/gh-pages/.github/workflows/main.yml

Finally got it to work. 

  1. Copy the .github/workflow to the branch gh-pages 

  2. branches-ignore was the only filter that worked

    name: deploy on server
    on:
    push:
    branches-ignore:
    - master
    jobs:
    build:
    name: Build
    runs-on: ubuntu-latest
    steps:
    - name: multiple command
    uses: appleboy/ssh-action@master
    with:
    host: ${{ secrets.HOST }}
    username: ${{ secrets.USERNAME }}
    key: ${{ secrets.key }}
    port: ${{ secrets.PORT }}
    script: |
    whoami
    ls -al