wagoid / commitlint-github-action

Lints Pull Request commits with commitlint
MIT License
363 stars 57 forks source link

Ignore 'Initial commit' #640

Open fadnincx opened 1 year ago

fadnincx commented 1 year ago

Problem description

When you have a template repo that contains action, creating a new repo from this template will always result in a failed pipeline because the initial commit Github makes to insert everything from the template into the repo will be called "Initial commit".

How to reproduce

  1. Create a new repo from a template containing this action. For example projectpotos/ansible-role-potos_template.
  2. Wait until pipeline is done
  3. You can see that the commitlint pipeline is failing

Proposed solution

If the first commit is called "Initial commit" this should be accepted. One might be able to allow this only conditionally with a variable to not change current default behavior

Additional infos

My Worflow file

---

name: Lint Commit message

on:
  push:
  pull_request:
  workflow_call:

jobs: 
  commitlint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - uses: wagoid/commitlint-github-action@v5

Log (relevant part)

2023-01-12T09:57:09.3575866Z ##[group]Run wagoid/commitlint-github-action@v5
2023-01-12T09:57:09.3576128Z with:
2023-01-12T09:57:09.3576324Z   configFile: ./commitlint.config.js
2023-01-12T09:57:09.3576560Z   firstParent: true
2023-01-12T09:57:09.3576764Z   failOnWarnings: false
2023-01-12T09:57:09.3577083Z   helpURL: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
2023-01-12T09:57:09.3577567Z   token: ***
2023-01-12T09:57:09.3577742Z ##[endgroup]
2023-01-12T09:57:09.3809901Z ##[command]/usr/bin/docker run --name wagoidcommitlintgithubaction530_45aaac --label ea425b --workdir /github/workspace --rm -e "INPUT_CONFIGFILE" -e "INPUT_FIRSTPARENT" -e "INPUT_FAILONWARNINGS" -e "INPUT_HELPURL" -e "INPUT_COMMITDEPTH" -e "INPUT_TOKEN" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/ansible-role-potos_firewall/ansible-role-potos_firewall":"/github/workspace" wagoid/commitlint-github-action:5.3.0
2023-01-12T09:57:11.6442148Z ##[error]You have commit messages with errors

⧗   input: Initial commit
✖   subject may not be empty [subject-empty]
✖   type may not be empty [type-empty]

✖   found 2 problems, 0 warnings
ⓘ   Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
jdbruijn commented 1 year ago

IMO this is not necessary caused by this action but rather just something in the commitlint configuration. So the Initial commit should then be added to https://github.com/conventional-changelog/commitlint/blob/v17.5.1/%40commitlint/is-ignored/src/defaults.ts#L17-L29.