github / issue-labeler

An action for automatically labelling issues

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

support reading from filesystem rather than using the API to fetch configuration file

lrstanley opened this issue · comments

Looks as though the action is currently hardcoded to use the API to pull the configuration file, as shown below:

issue-labeler/src/main.ts

Lines 133 to 138 in 772f647

const response = await client.repos.getContents({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
path: repoPath,
ref: github.context.sha
});

However, with reusable workflows being a thing, where one might want to centralize some of the common configurations in a .github repository, this doesn't work, unless the config is in the target repo, rather than the reusable repository.

Below is an example workflow, that is a reusable workflow, and it clones my personal lrstanley/.github repository, where most of my triage-related configuration files are stored. I'd like to be able to read from that repo.

name: triage

on: [workflow_call]

jobs:
  issues:
    runs-on: ubuntu-latest
    permissions:
      issues: write
      contents: read
    steps:
      - name: git-clone-tools-repo
        uses: actions/checkout@v3
        with:
          repository: lrstanley/.github
      - name: label-issues
        uses: github/issue-labeler@99b4c5dda477c65f4ef08486b73c5787e1e33601
        with:
          repo-token: "${{ secrets.GITHUB_TOKEN }}"
          configuration-path: triage/label-issues.yml
          enable-versioned-regex: 0

Most actions I've used so far (esp. relating to labeling), will read from a local file for the configuration. It would be nice if this action could support first trying to see if $PWD/<configuration-path> exists, and if not, falling back to using the content API.