skip to Main Content

I have the following yml file as my GitHub workflow:

name: Lint and Test Charts

on:
  push:
    branches: [ main/master ]
  pull_request:
    branches: [ main/master ]
    paths:
      - 'open-electrons-monitoring/**'
      - "!**/README.md"
      - "!images/**"
      - "!README.md"

jobs:
  lint-test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Install Helm
        uses: azure/setup-helm@v1

      - uses: actions/setup-python@v2
        with:
          python-version: 3.7

      - name: Install chart-testing
        uses: helm/[email protected]

      - name: Run chart-testing (list-changed)
        id: list-changed
        run: |
          changed=$(ct list-changed)
          if [[ -n "$changed" ]]; then
            echo "::set-output name=changed::true"
          fi

      - name: Run chart-testing (lint)
        run: ct lint

      - name: Create kind cluster
        uses: helm/[email protected]
        if: steps.list-changed.outputs.changed == 'true'

      - name: Run chart-testing (install)
        run: ct install

This file is defined inside .github/workflows and as it can be seen that I want to run it upon any push to the master branch. But strangely it seems not to be triggered. I also checked my default branch which is master, so I do not see any reason as to why this should not get triggered?

enter image description here

3

Answers


  1. Your branch specification is incorrect. main/master means "a branch called main/master, and that doesn’t seem to exist on your repo. What you probably want is an array:

    on:
      push:
        branches:
          - main
          - master
      pull_request:
        branches:
          - main
          - master
    ...
    
    Login or Signup to reply.
  2. If your branch is called main/master it’s correct, instead if your branch is just master or main I think you need to change the ON condition like following

    name: Lint and Test Charts
    
    on:
      push:
        branches:
          - main
          - master
      pull_request:
        branches: 
          - main
          - master
        paths:
          - 'open-electrons-monitoring/**'
          - "!**/README.md"
          - "!images/**"
    
    Login or Signup to reply.
  3. Edit value of key branches to

    on:
      push:
        branches:
         - main
         - master
      pull_request:
        branches:
         - main
         - master
        paths:
          - 'open-electrons-monitoring/**'
          - "!**/README.md"
          - "!images/**"
          - "!README.md"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search