aevea / commitsar

Tool to check that commits comply with conventional commit standard
https://commitsar.aevea.ee
MIT License
134 stars 19 forks source link

Configure GitHub action #516

Open pburgisser opened 11 months ago

pburgisser commented 11 months ago

Hi,

I'm trying to use commitsar as a GH Action with my own config file but I don't know how to set the config in the action I tried the following combinations:

env:
  COMMITSAR_CONFIG_PATH: ".github/linters/commitsar.yaml"
# or
with:
  COMMITSAR_CONFIG_PATH: ".github/linters/commitsar.yaml"
# or
with:
  config: '.github/linters/commitsar.yaml'
# or
env:
   config: '.github/linters/commitsar.yaml'

But at run, commitsar says there is no config file set:

Run aevea/commitsar@v0.20.2
  with:
    config: .github/linters/commitsar.yaml
  env:
    config: .github/linters/commitsar.yaml
/usr/bin/docker run --name bba96d741a5cf4cf59[3](https://github.com/xxxxxx/actions/runs/6265205933/job/17013518497#step:4:3)f5c[4](https://github.com/xxxxx/actions/runs/6265205933/job/17013518497#step:4:4)40e1a94fc[5](https://github.com/xxxxx/actions/runs/6265205933/job/17013518497#step:4:5)_09f511 --label 94351b --workdir /github/workspace --rm -e "config" -e "INPUT_CONFIG" -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_ENVIRONMENT" -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/xxxxxx":"/github/workspace" xxxxx:ba9[6](https://github.com/xxxxx/actions/runs/xxxxxx/job/xxxxxx#step:4:7)d741a5cf4cf593f5c440e1a94fc5

2023/09/21 17:44:25 config file not found, using defaults
   • Starting pipeline: commit-pipeline
   • Starting analysis of commits on branch HEAD

eg: of my action:

name: Linters

on: [pull_request]

jobs:
  validate-commits:
    runs-on: ubuntu-latest
    steps:
      - name: Check out code into the Go module directory
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Commitsar check
        #uses: docker://aevea/commitsar
        uses: aevea/commitsar@v0.20.2
        with:
          config: '.github/linters/commitsar.yaml'
        env:
          config: '.github/linters/commitsar.yaml'

eg of my config:

commits:
  limit: 1

Thanks a lot

jeanplevesque commented 8 months ago

I managed to make it work using environment variables like this:

(...)
- name: Commitsar check
  uses: docker://aevea/commitsar
  env:
    COMMITSAR_CONFIG_PATH : ./.github

My repository is structured like this: image