Search code examples
githubyamlpytestgithub-actions

Workflow not showing up in GitHub Actions


I am doing a continuous integration workflow in GitHub Actions to trigger "pytest backend/tests/" command on a push to any branch. Right now, I am testing in a feature branch. The pytest.yml file is located in /.github/workflows/. The GitHub actions is not showing my workflow, even after I push new changes.

This is my pytest.yml file

name: Run pytest on push

on:
  push:
    branches:
      - '*'

jobs:
  pytest:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v2

    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: 3.9

    - name: Install dependencies
      run: pip install -r requirements.txt

    - name: Run pytest
      run: pytest backend/tests

Solution

  • Your workflow will not show up in the Actions tab until it's merged to the main branch.

    The reason is because certain triggers (like push, workflow_dispatch) requires the new workflow to be merged to main branch first before showing up in Actions tab.

    So to solve this, you can instead use the pull_request trigger, like:

    on:
      pull_request:
    

    Then the action should come up in the Actions tab, even before you merge your changes to the main branch.