thehanimo / pr-title-checker

An action to automatically check if pull request titles conform to Contribution Guidelines
MIT License
109 stars 36 forks source link

local_configuration_path insert current working directory before absolute path #47

Open GMZwinge opened 8 months ago

GMZwinge commented 8 months ago

I am trying to encapsulate the config file with my own shared action that calls your action. My shared action includes my config file that is passes to your action. That way, multiple repos can call my shared action to check PR title consistently.

For this, I would like my action to call your action like this:

name: Check PR title
description: Check that the PR title conforms to the Contribution Guidelines embedded in this action.
runs:
  using: composite
  steps:
    - uses: thehanimo/pr-title-checker@v1.4.2
      with:
        GITHUB_TOKEN: ${{ github.token }}
        local_configuration_path: ${{ github.action_path }}/pr-title-checker-config.json

where pr-title-checker-config.json is in the same location as my action.yaml. The action thehanimo/pr-title-checker seems to prefix the local_configuration_path with the path to the folder of the workflow calling my shared action. The output is:

Using local config file /home/runner/_work/_actions/<ActionOwner>/<ActionRepo>/<GitRef>/.github/actions/pr-title-check/pr-title-checker-config.json
Error: Couldn't retrieve or parse the config file specified - Error: ENOENT: no such file or directory, open
'/home/runner/_work/<WorkflowRepo>/<WorkflowRepo>/home/runner/_work/_actions/<ActionOwner>/<ActionRepo>/<GitRef>/.github/actions/pr-title-check/pr-title-checker-config.json'

The workaround is to use this:

        local_configuration_path: ../../../../..${{ github.action_path }}/pr-title-checker-config.json
thehanimo commented 8 months ago

Just to make sure I understand this correctly, the config file you want to use does not live in the repo that calls the action, correct? The repo calls your action, whose repo contains the config? How about using a remote config link or a GitHub repo config if it is private?

GMZwinge commented 8 months ago

@thehanimo That is correct. The repo of the workflow that calls my action does not contain the config file. The config file lives in the repo containing my called action that calls your action. A remote config link or a GitHub repo config would probably works, but it's more complicated and it defeats the purpose of ${{ github.action_path }} that can be used to access files located in the same repository as the action according to github.action_path in github context.

To not break backward compatibility, there could be a new input named for example absolute_configuration_path that to handle the use of ${{ github.action_path }}.