From 00584cab2cbc328378954e1fceeb1ec20c4dfb75 Mon Sep 17 00:00:00 2001 From: Callum Silcock Date: Thu, 26 Sep 2019 16:53:38 +0100 Subject: [PATCH] Reworded readme with clearer examples * Reformatted readme into headings with some basic rewording * Added basic and common examples Resolves #24 --- README.md | 46 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 13e7e98a..59312891 100644 --- a/README.md +++ b/README.md @@ -2,24 +2,46 @@ Pull request labeler triages PRs based on the paths that are modified in the PR. -To use, create a `.github/labeler.yml` file with a list of labels and [minimatch](https://github.com/isaacs/minimatch) -globs to match to apply the label. +## Usage -Example: -``` +### Create `.github/labeler.yml` + +Create a `.github/labeler.yml` file with a list of labels and [minimatch](https://github.com/isaacs/minimatch) globs to match to apply the label. + +The key is the name of the label in your repository that you want to add (eg: "merge conflict", "needs-updating") and the value is the path (glob) of the changed files (eg: `src/**/*`, `tests/*.spec.js`) + +#### Basic Examples + +```yml +# Add 'label1' to any changes within 'example' folder or any subfolders label1: -- example1/**/* + - example/**/* +# Add 'label2' to any file changes within 'example2' folder label2: example2/* - -label3: -- example3/* -- example3/**/*.yml ``` -Where `"label1"` is the name of the label on your repository that you want to add (eg: "merge conflict", "needs-updating") and `"example1/**/*"` is the path of the changed files. +#### Common Examples + +```yml +# Add 'repo' label to any root file changes +repo: + - ./* + +# Add '@domain/core' label to any change within the 'core' package +@domain/core: + - package/core/* + - package/core/**/* + +# Add 'test' label to any change to *.spec.js files within the source dir +test: + - src/**/*.spec.js +``` + +### Create Workflow + +Create a workflow (eg: `.github/workflows/labeler.yml` see [Creating a Workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file)) to utilize the labeler action with content: -Then create a workflow (eg: `.github/workflows/label.yml` see [Creating a Workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file)) utilizing the labeler action, granting access to the GITHUB_TOKEN so the action can make calls to GitHub's rest API: ``` name: "Pull Request Labeler" on: @@ -33,3 +55,5 @@ jobs: with: repo-token: "${{ secrets.GITHUB_TOKEN }}" ``` + +_Note: This grants access to the `GITHUB_TOKEN` so the action can make calls to GitHub's rest API_