KieranLewin
KieranLewin

Reputation: 2290

GitHub Action workflow not running

I have a GitHub action workflow file @ myrepo/.github/workflows/Build Webpage.yml it contains this:

name: Webpage Build

on:
  push:
    branches:
      - webpage 

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: setup node
      uses: actions/setup-node@v2-beta
      with:
        node-version: '12'
    - name: install deps and predeploy
      run: |
        npm ci
        npm run predeploy
    - name: Deploy 
      uses: JamesIves/[email protected]
      with:
        GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
        BRANCH: gh-pages
        FOLDER: build

When I push to the webpage branch nothing happens in the actions tab at all I can't tell if I have a syntax error or if something is completely not set up correctly, I have in past on this repo had errors relating to syntax like every step must define a 'uses' or 'run' key which to me shows Github does recognize the workflow

Upvotes: 150

Views: 177268

Answers (30)

sachinkondana
sachinkondana

Reputation: 671

Another scenario: if you already have a workflow file in your project and the paths are set, the workflow will not execute unless changes are made within the specified path folder. Any modifications to the workflow file located outside the defined path will not trigger the Action.

on:
  push:
    branches:
     - master
    paths:
     - 'packages/container/**'

Upvotes: 38

Matt Komarnicki
Matt Komarnicki

Reputation: 5422

In my case I was expecting workflow to be triggered on my bugfix branch, yet I forgot to specify it in the config.

name: CI
on:
  push:
    branches: [ master, develop, feature/** ]

Added bugfix/** and the trigger works.

Upvotes: 0

Attila Naghi
Attila Naghi

Reputation: 2686

In my case, it was the paths the issue. It had it like this:

on:
  push:
    branches:
      - develop
    paths:
      - '.github/workflows/deploy_dev.yml'

Once I removed the:

paths:
  - '.github/workflows/deploy_dev.yml'

It worked! Hope this will help someone!

Upvotes: 1

Biobele Johnbull
Biobele Johnbull

Reputation: 21

When I had this issue, the branch in my .yml (workflow file) file was not the branch I wanted to push to - as in git push origin "main" - right? For example, my "main" branch was where I was trying to push to whereas in my .yml file (workflow file) it had master in there. I changed it and everything worked perfectly!

Upvotes: 1

Petra1999
Petra1999

Reputation: 65

I also have a silly answer to this. I had all files/folders starting with "." in my gitignore, so the workflow file itself wasn't in my repo. Fixed it, then it worked! So, basically: Check that your workflow file isn't in your gitignore.

Upvotes: 1

Soumya Sagar
Soumya Sagar

Reputation: 11

this may sound a bit funny but sometimes the name of action also matter. For example in my case:

i changed a action named pre-releases.yml to pre_releases.yml

so my advice is keep name simple.

Upvotes: 1

KieranLewin
KieranLewin

Reputation: 2290

So as found in the comment below the post itself, if you want the workflow to run on branch x the .github folder must be on branch x and any other branch you want to trigger the workflow from

Upvotes: 77

Moshisho
Moshisho

Reputation: 2951

Make sure to go to "Actions" tab and see if your run was errored. In my case, the check was pending on the PR view, because I changed a secret name in one workflow, but forgot to change in the calling workflow.

However, when I went to "Actions" tab I saw that my workflow was unable to run because the inputs don't match although required: true.

Upvotes: 4

Tofandel
Tofandel

Reputation: 3555

The last possibility is that your workflow was automatically disabled because there was no update to the project in 90 days

I which case you need to go to the page of each specific workflow and click on the warning to reenable them (you will not see the warning in the All workflows page even if you only have one)

Upvotes: 2

FuriousD
FuriousD

Reputation: 2131

In my case there was a Github actions outage. Check https://www.githubstatus.com/

Upvotes: 197

stackich
stackich

Reputation: 5207

Please double check everything

Stupid mistake I made was naming a github folder with whitespace at the end, so on Github it was looking like .github /workflows(notice the space before the slash sign) instead of .github/workflows.

I have changed the folder name from github to github and pushed, and the workflow started running immediately.

Upvotes: 1

IllusionVK
IllusionVK

Reputation: 93

Does your branch name have any of these characters in it: + ? ! * ** ? and do you only run the workflow on pushes to that branch ?

Ours had these characters and so the workflow was not being triggered. Once we escaped out these characters by adding \ before them everything worked as expected.

Reference to GitHub documents here https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpull_requestpull_request_targetbranchesbranches-ignore

Upvotes: 1

Mohsenasm
Mohsenasm

Reputation: 3141

If the repo is new, make sure to wait 5-10 minutes.

Upvotes: 4

mmik
mmik

Reputation: 5961

Suppose you have checked the branch and validated the actions, but the workflow isn't running. In that case, there's a high chance you need to enable read and write permissions from the relevant repository settings (top right corner) → Actions (left navigation bar) → General → Workflow permissions section.

GitHub repository settings enter image description here GitHub repository settings read and write permissions

Upvotes: 4

Chris Hillery
Chris Hillery

Reputation: 441

And another silly possibility to watch out for - I had something like

on:
  push:
    branches:
      - 'TTG-.*'
      - 'FRD-.*'

But it turns out that valid values for "branch expression" are globs, not regular expressions. So those periods in the branch names were being interpreted literally. I needed to change to

on:
  push:
    branches:
      - 'TTG-*'
      - 'FRD-*'

Upvotes: 1

Jesus Redon
Jesus Redon

Reputation: 41

Today I had this issue, the same yaml file was working fine in other branches, but not in my new one(feature/somename). The solution was to rename the branch without using the slash ("/")

Upvotes: 1

fr_andres
fr_andres

Reputation: 6667

Is your branch master or main?

It might be silly in the future but as for October 2020 just keep in mind that the default GitHub branch has been renamed from master to main (source).

So if you are copypasting actions from elsewhere, make sure that you are targeting the correct branch (for new repos this means most of the time to replace master with main in the .yml workflow files).

If you are targeting the wrong branch, the name of the action will appear on GitHub but no actions will actually run.

Upvotes: 271

builder_247
builder_247

Reputation: 205

If your commit is made by another action using the repository's GITHUB_TOKEN, the other workflow will not run.

You can fix this by creating a personal access token with write permission.

name: Push changes
    - uses: actions/checkout@v2
      with:
        token: ${{ secrets.PAT }}

Upvotes: 4

Andrew J Hanlon
Andrew J Hanlon

Reputation: 49

You may need to merge your new workflow file into your Default branch for that repository. That was the only way I could get my workflow (for another branch) to appear on the GitHub Actions page. enter image description here

Upvotes: 2

Arif Wibawa
Arif Wibawa

Reputation: 59

Just make sure your .yml file on push and pull_request is the right target. Look at your main branch first, is it master or main ?

on: 
  push:
    branches: [ main/master ]
  pull_request:
    branches: [ main/master ]

Upvotes: 3

sidharth vijayakumar
sidharth vijayakumar

Reputation: 1571

In my case what I needed to run a workflow in pylint branch but it was not working until I added the same workflow in the main branch.In the main branch I added .github/workflows and then the yml file of the workflow which I wanted to run.

Once this was done i went to the pylint branch and then in the workflow I added pylint under the branches. After doing this workflow was getting triggered after every commit

name: Python Notebooks Linting
on:
  push:
    branches:
      - 'main'
      - 'pylint'

Upvotes: 3

Emre
Emre

Reputation: 899

For me, accidentally had named the folder .github/workspaces instead of .github/workflows.

Upvotes: 6

mattste
mattste

Reputation: 380

Be aware that you can't have nested folders. For example, .github/workflows/folder-1/my_workflow.yml will not be recognized by Github. In my case, I had to change it to .github/workflows/my_workflow.yml

Upvotes: 9

Anton
Anton

Reputation: 1126

In my case my workflow was not triggering because I was using double quotes inside a bash command which messed up the yml parsing.

You can check this on VSCode by seeing if the syntax highlighting looks off.

Upvotes: 4

dvdblk
dvdblk

Reputation: 2905

I found that my issue was described in the GitHub actions docs:

If you define a branch with the ! character, you must also define at least one branch without the ! character. If you only want to exclude branches, use branches-ignore instead.

Originally, I had this in my workflow (which didn't trigger the action):

on:
  push:
    branches:
      - "!main"

To fix it:

on:
  push:
    branches-ignore:
      - main

Upvotes: 12

tjg184
tjg184

Reputation: 4676

Other possibility that can occur on a workflow is the following with pull_request type.

If there are conflicts with your branch and base branch, workflow will not trigger. It's not always obvious because it's possible that the only conflicts you have is with workflows.

Just an example below, but main point is conflicts must be resolved first.

on:
  pull_request:
    types: [labeled, reopened, synchronize, ready_for_review]

Upvotes: 23

pegiadise
pegiadise

Reputation: 689

The last gotcha to be aware, are the skip keywords in the commit that triggers the action.

If any commit message in your push or the HEAD commit of your PR contains the strings [skip ci], [ci skip], [no ci], [skip actions], or [actions skip] workflows triggered on the push or pull_request events will be skipped.

I was bitten by that while working with Semantic Release and then resetting my deployment branches to the release commits. You can just reword the release commit and push (at least that's how I resolved it) in your deployment branch.

Upvotes: 14

Jehad Nasser
Jehad Nasser

Reputation: 3545

  • Another silly case scenario that happened to me. As the GitHub UI adds spaces to the folders path (sometimes this is caused by the Google Translate plugin), when I copied the path .github/workflows from the GitHub UI and used it to create folders in VSCode, it was .github / workflows with spaces around the /.

GitHub workflow path

  • I caught this by asking GitHub to initialize the Actions workflow for me from the Actions tab, so I noticed my mistake, and that's a good way to solve this issue.

GitHub Actions UI

Upvotes: 27

A248
A248

Reputation: 804

A further trap to look out for: If you fork another repository which has a Github workflow, workflows will be disabled in your fork by default.

The intention of this feature is to prevent you from accidentally running an imported workflow with unknown behavior, which might pose a security hazard (e.g. by accessing secrets).

To re-enable workflows, go to the "Actions" tab of the repository and confirm that you understand the workflows you are about to enable.

Upvotes: 17

anmol gomra
anmol gomra

Reputation: 203

Just wanted to add a silly case scenario that happened to me. Whenever you add a new workflow, sometimes it may happen that workflow may not get into the running phase even after everything is specified correctly. Just make sure to make some changes in whatever branch you are running the action in after adding the action itself. Make sure to commit these changes as well. This will trigger the action to run and show up on the dashboard.

Upvotes: 20

Related Questions