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

use typescript for main action file; add option to use local filepaths #36

Closed smzelek closed 1 year ago

smzelek commented 1 year ago

hi! I'm happy to change anything here

my team had a need to use a predownloaded, local filepath (instead of one that was hosted in the same repo).

while I was at it I changed this to use TypeScript.

I just wanted to offer up this PR as a starting point for conversation; let me know if you're super opposed to this

thehanimo commented 1 year ago

This is great! Typescript also seems to package the action really well. When you say local filepath, was this present in the same repo that the action's code is in? This will be useful if this repo is forked, a config is added into that fork, and any repo could then use that action (from the fork) with the pre-defined config in it, correct?

smzelek commented 1 year ago

@thehanimo

At my company we use an action in a previous step to pull a file from a private repo shared across the organization, so that we can reuse the same config file for the PR Title Checker action across all of our team's repos. Then in the context of the Github Actions workflow, the file is now locally available and doesn't have to be fetched while this action runs.

So yes, similarly the config file could also be local to the repo running the action, and checked into a branch, fork, etc. Correct!

smzelek commented 1 year ago

This is how our setup works, since we don't want a config file committed in every individual repo. We have a shared config in the repo that we checkout here.

But you could just checkout the same repo that is running this action instead and use a locally committed config.

name: Enforce PR Titles

on:
  workflow_call:

jobs:
  enforce-pr-title:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo with config file
        uses: actions/checkout@v3
        with:
          repository: ...
          ref: v4
          ssh-key: ${{ secrets.... }}
          path: .github/actions
      - name: Enforce PR Title
        uses: smzelek/pr-title-checker@v1.3.7
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          pass_on_octokit_error: false
          configuration_path: ".github/actions/enforce-pr-titles/config.json"
          use_local_configuration_file: true
thehanimo commented 1 year ago

Thank you! I do not want to make changes to your main branch since you may be using it in your repos. I will merge this into dev and add support for external links (#28) and make a few changes.