5

My build_and_test.yml file in .github/workflows is as follows:

name: CI on: push: branches: - main - name-of-my-branch pull_request: branches: - main jobs: build: # Code to build 

However, when I push to any branch other than the main branch, the build doesn't trigger. Any ideas why this might be?

3 Answers 3

17

I realized that this Github Actions file was on the main branch, and Github uses the actions that are configured for the branch that is getting pushed. It doesn't do anything if name-of-my-branch has different on: push: branches: specified in its .github/workflows/build_and_test.yml. So branches: name-of-my-branch in the main branch is a bit deceptive - a build-on-push will only occur if that branch is specified under push in its own .yml.

I pulled from main to name-of-my-branch to update the build_and_test.yml, pushed, and the build was triggered.

Sign up to request clarification or add additional context in comments.

1 Comment

You ended up helping me too. My .github/ was inside the terraform folder. I just moved to the root folder of the repo and it worked
1

Based on experience, another possibility is that the .github directory and the yaml file in it have not been staged even when doing git add *. So no action was triggered when you pushed.

I had to do git add .github/workflows/myaction.yml specifically to have it staged.

1 Comment

This fixed my issue. Everything was working fine a few days ago, but today it's just not starting no matter how I push new changes from VS code. After this manually add, VS Code works again too, weird.
0

This worked for me - https://github.com/actions/checkout/discussions/277#discussioncomment-1522374 e.g. - feature/branch_name

My branches names are feature/my_branch

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.