26
votes

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

6
does github still complain about the syntax? - smac89
No, no matter what I push to nothing happens, no complaints no errors that I can see - KieranLewin
If you are absolutely sure you are pushing to the webpage branch, and still the workflow is not being triggered, then you need to head over to the official actions community page and submit a bug report - smac89
If you want to debug it further, another option is to change the trigger to run on a schedule, and see if that triggers the workflow... - smac89
found it was confused with basic git file... Im an idiot obvs XD, just pushed the workflow up and its running so that looks fine, so in short make sure the workflows on the branch you want it to run on. I thought I saw it in a doc somewhere but couldn't find it. Thanks a bunch - KieranLewin

6 Answers

65
votes

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.

Hope this helps someone during this transition!

16
votes

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

4
votes

One more case, suppose if you already have workflow file inside project and if your paths set then the workflow will not RUN unless you make changes inside path folder. So if you make any changes to your workflow which kept outside of path won't trigger Action

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

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.

3
votes
  • Another silly case scenario that happened to me. As Github UI adds spaces to the folders path (sometime this is caused by Google translate plugin if your browser has it), so when I copied the path .github/workflows from Github UI and use it to create folders in VCode, it was .github / workflows with spaces around /

enter image description here

  • I catched 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 regarding of the reason.

enter image description here

1
votes

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.