Home > Enterprise >  workflow in not getting triggered in my project
workflow in not getting triggered in my project

Time:12-15

I am trying to use this workflow in my GitHub project, https://github.com/webex/pr-title-checker Above one if forked from https://github.com/thehanimo/pr-title-checker

I have created

config file .github/pr-title-checker-config.json

{
    "LABEL": {
      "name": "Title needs formatting",
      "color": "EEEEEE"
    },
    "CHECKS": {
      "prefixes": ["build", "chore", "ci", "docs", "feat", "fix", "perf", "refactor", "revert", "test"],
      "regexp": "docs\\(v[0-9]\\): ",
      "regexpFlags": "i",
      "ignoreLabels" : ["dont-check-PRs-with-this-label", "meta"]
    },
    "MESSAGES": {
      "success": "All OK",
      "failure": "Failing CI test",
      "notice": ""
    }
}

workflow file .github/workflows/pr-title-checker.yml

name: "PR Title Checker"
on:
  pull_request_target:
    types:
      - opened
      - edited
      - synchronize
      - labeled
      - unlabeled

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: webex/pr-title-checker
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          pass_on_octokit_error: false
          configuration_path: ".github/pr-title-checker-config.json"

But I am noticing my workflow is not getting triggered. Can someone please help me ? Earlier It was triggering but now I's now/

I want my workflow should be triggered always in any change, push, pr title update etc. on any branch (my code is present in beta branch)

Thanks.

CodePudding user response:

After doing some research and changes, I am able to run the workflow with pr title check,

Few basic points need to understand -

  1. Workflows are defined by a YAML file, always validate your yml before using, some time because of formatting it didn't trigger events.

  2. - uses: providing the correct values for uses, tags, branches and shas should only be used https://docs.github.com/en/actions/learn-github-actions/finding-and-customizing-actions#using-release-management-for-your-custom-actions

  3. Always use correct events, https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#using-filters-to-target-specific-branches-for-pull-request-events

Updated code looks like this -

# This workflow/action checks if PR titles conform to the Contribution Guidelines
# For more information, see: https://github.com/webex/pr-title-checker

name: pr-title-checker
on:
  pull_request_target:
    types:
      - opened
      - edited
      - synchronize
      - labeled
      - unlabeled
    branches:
      - main
      - dev
      - beta
jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - name: Check PR title
        uses: webex/pr-title-checker@main
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          pass_on_octokit_error: false
          configuration_path: .github/pr-title-checker-config.json
  • Related