mirror of
https://github.com/actions/labeler.git
synced 2025-12-12 20:51:42 +00:00
Compare commits
8 Commits
v5.0.0-alp
...
check_dist
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5189af2017 | ||
|
|
feaa12919d | ||
|
|
7ad42be42d | ||
|
|
fc2badc92d | ||
|
|
92ee5c6319 | ||
|
|
f4547bdc4d | ||
|
|
45fbda5933 | ||
|
|
6a1dea0fee |
@@ -1,7 +0,0 @@
|
|||||||
# Ignore list
|
|
||||||
/*
|
|
||||||
|
|
||||||
# Do not ignore these folders:
|
|
||||||
!__tests__/
|
|
||||||
!__mocks__/
|
|
||||||
!src/
|
|
||||||
50
.eslintrc.js
50
.eslintrc.js
@@ -1,50 +0,0 @@
|
|||||||
// This is a reusable configuration file copied from https://github.com/actions/reusable-workflows/tree/main/reusable-configurations. Please don't make changes to this file as it's the subject of an automatic update.
|
|
||||||
module.exports = {
|
|
||||||
extends: [
|
|
||||||
'eslint:recommended',
|
|
||||||
'plugin:@typescript-eslint/recommended',
|
|
||||||
'plugin:eslint-plugin-jest/recommended',
|
|
||||||
'eslint-config-prettier'
|
|
||||||
],
|
|
||||||
parser: '@typescript-eslint/parser',
|
|
||||||
plugins: ['@typescript-eslint', 'eslint-plugin-jest'],
|
|
||||||
rules: {
|
|
||||||
'@typescript-eslint/no-require-imports': 'error',
|
|
||||||
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
||||||
'@typescript-eslint/no-explicit-any': 'off',
|
|
||||||
'@typescript-eslint/no-empty-function': 'off',
|
|
||||||
'@typescript-eslint/ban-ts-comment': [
|
|
||||||
'error',
|
|
||||||
{
|
|
||||||
'ts-ignore': 'allow-with-description'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'no-console': 'error',
|
|
||||||
'yoda': 'error',
|
|
||||||
'prefer-const': [
|
|
||||||
'error',
|
|
||||||
{
|
|
||||||
destructuring: 'all'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'no-control-regex': 'off',
|
|
||||||
'no-constant-condition': ['error', {checkLoops: false}]
|
|
||||||
},
|
|
||||||
overrides: [
|
|
||||||
{
|
|
||||||
files: ['**/*{test,spec}.ts'],
|
|
||||||
rules: {
|
|
||||||
'@typescript-eslint/no-unused-vars': 'off',
|
|
||||||
'jest/no-standalone-expect': 'off',
|
|
||||||
'jest/no-conditional-expect': 'off',
|
|
||||||
'no-console': 'off',
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
env: {
|
|
||||||
node: true,
|
|
||||||
es6: true,
|
|
||||||
'jest/globals': true
|
|
||||||
}
|
|
||||||
};
|
|
||||||
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -1,4 +1,4 @@
|
|||||||
* text=auto eol=lf
|
* text=auto
|
||||||
.licenses/** -diff linguist-generated=true
|
.licenses/** -diff linguist-generated=true
|
||||||
|
|
||||||
# don't diff machine generated files
|
# don't diff machine generated files
|
||||||
|
|||||||
35
.github/ISSUE_TEMPLATE/bug_report.md
vendored
35
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,35 +0,0 @@
|
|||||||
---
|
|
||||||
name: Bug report
|
|
||||||
about: Create a bug report
|
|
||||||
title: ''
|
|
||||||
labels: bug, needs triage
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
<!--- Please direct any generic questions related to actions to our support community forum at https://github.community/c/code-to-cloud/github-actions/41 --->
|
|
||||||
<!--- Before opening up a new bug report, please make sure to check for similar existing issues -->
|
|
||||||
|
|
||||||
**Description:**
|
|
||||||
A clear and concise description of what the bug is.
|
|
||||||
|
|
||||||
**Action version:**
|
|
||||||
Specify the action version
|
|
||||||
|
|
||||||
**Platform:**
|
|
||||||
- [ ] Ubuntu
|
|
||||||
- [ ] macOS
|
|
||||||
- [ ] Windows
|
|
||||||
|
|
||||||
**Runner type:**
|
|
||||||
- [ ] Hosted
|
|
||||||
- [ ] Self-hosted
|
|
||||||
|
|
||||||
**Repro steps:**
|
|
||||||
A description with steps to reproduce the issue. If your have a public example or repo to share, please provide the link.
|
|
||||||
|
|
||||||
**Expected behavior:**
|
|
||||||
A description of what you expected to happen.
|
|
||||||
|
|
||||||
**Actual behavior:**
|
|
||||||
A description of what is actually happening.
|
|
||||||
1
.github/ISSUE_TEMPLATE/config.yml
vendored
1
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1 +0,0 @@
|
|||||||
blank_issues_enabled: false
|
|
||||||
18
.github/ISSUE_TEMPLATE/feature_request.md
vendored
18
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
name: Feature request
|
|
||||||
about: Suggest an idea for this project
|
|
||||||
title: ''
|
|
||||||
labels: feature request, needs triage
|
|
||||||
assignees: ''
|
|
||||||
---
|
|
||||||
<!--- Please direct any generic questions related to actions to our support community forum at https://github.community/c/code-to-cloud/github-actions/41 --->
|
|
||||||
<!--- Before opening up a new feature request, please make sure to check for similar existing issues and pull requests -->
|
|
||||||
|
|
||||||
**Description:**
|
|
||||||
Describe your proposal.
|
|
||||||
|
|
||||||
**Justification:**
|
|
||||||
Justification or a use case for your proposal.
|
|
||||||
|
|
||||||
**Are you willing to submit a PR?**
|
|
||||||
<!--- We accept contributions! -->
|
|
||||||
9
.github/pull_request_template.md
vendored
9
.github/pull_request_template.md
vendored
@@ -1,9 +0,0 @@
|
|||||||
**Description:**
|
|
||||||
Describe your changes.
|
|
||||||
|
|
||||||
**Related issue:**
|
|
||||||
Add link to the related issue.
|
|
||||||
|
|
||||||
**Check list:**
|
|
||||||
- [ ] Mark if documentation changes are required.
|
|
||||||
- [ ] Mark if tests were added or updated to cover the changes.
|
|
||||||
17
.github/workflows/basic-validation.yml
vendored
17
.github/workflows/basic-validation.yml
vendored
@@ -1,17 +0,0 @@
|
|||||||
name: Basic validation
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
paths-ignore:
|
|
||||||
- '**.md'
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- releases/*
|
|
||||||
paths-ignore:
|
|
||||||
- '**.md'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
call-basic-validation:
|
|
||||||
name: Basic validation
|
|
||||||
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
|
|
||||||
28
.github/workflows/build_test.yml
vendored
Normal file
28
.github/workflows/build_test.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
name: Build & Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- releases/*
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Setup node 14
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: 14.x
|
||||||
|
- run: npm install
|
||||||
|
- run: npm run build
|
||||||
|
- run: npm test
|
||||||
17
.github/workflows/check-dist.yml
vendored
17
.github/workflows/check-dist.yml
vendored
@@ -1,17 +0,0 @@
|
|||||||
name: Check dist/
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
paths-ignore:
|
|
||||||
- '**.md'
|
|
||||||
pull_request:
|
|
||||||
paths-ignore:
|
|
||||||
- '**.md'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
call-check-dist:
|
|
||||||
name: Check dist/
|
|
||||||
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
|
|
||||||
19
.github/workflows/check_dist.sh
vendored
Executable file
19
.github/workflows/check_dist.sh
vendored
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
dist_index_diff=$(git diff --exit-code --text -- dist/index.js)
|
||||||
|
|
||||||
|
if [[ "$dist_index_diff" ]]; then
|
||||||
|
echo -e "$dist_index_diff\n‼️ Changes detected to dist/index.js! \n\tPlease run \`npm run build' and commit the result." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# - run: |
|
||||||
|
# if [[ "$(git status --porcelain)" != "" ]]; then
|
||||||
|
# echo "::set-output name=createPR::true"
|
||||||
|
# git config --global user.email "github-actions@github.com"
|
||||||
|
# git config --global user.name "github-actions[bot]"
|
||||||
|
# git checkout -b bots/updateGitHubDependencies-${{github.run_number}}
|
||||||
|
# git add .
|
||||||
|
# git commit -m "Update Dependencies"
|
||||||
|
# git push --set-upstream origin bots/updateGitHubDependencies-${{github.run_number}}
|
||||||
|
# fi
|
||||||
23
.github/workflows/check_dist.yml
vendored
Normal file
23
.github/workflows/check_dist.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Fails if any of dist/index.js needs to be rebuilt
|
||||||
|
|
||||||
|
name: Check dist/index.js
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- check_dist
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- check_dist
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check_dist:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Check dist/index.js for diffs
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- run: npm install
|
||||||
|
- run: npm run build
|
||||||
|
- run: "${GITHUB_WORKSPACE}/.github/workflows/check_dist.sh"
|
||||||
32
.github/workflows/check_license_status.yml
vendored
Normal file
32
.github/workflows/check_license_status.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Fails if any of our dependencies have licenses that our incompatible with our
|
||||||
|
# requirements (see .licensed.yml) OR if any of our dependencies have been
|
||||||
|
# upgraded to a new version without us having updated their corresponding
|
||||||
|
# license metadata file in .licenses/
|
||||||
|
#
|
||||||
|
# see https://github.com/actions/labeler/pull/91 for more context
|
||||||
|
|
||||||
|
name: Check License Status
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- licensed_cache_update
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check_license:
|
||||||
|
needs: update_licenses_cache
|
||||||
|
if: always() # always run after we update the license cache. if it failed, we will probably just fail as well
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Check License Status
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: jonabc/setup-licensed@v1.0.2
|
||||||
|
with:
|
||||||
|
version: '2.x'
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- run: npm install
|
||||||
|
- run: licensed status
|
||||||
14
.github/workflows/codeql-analysis.yml
vendored
14
.github/workflows/codeql-analysis.yml
vendored
@@ -1,14 +0,0 @@
|
|||||||
name: CodeQL analysis
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
pull_request:
|
|
||||||
branches: [main]
|
|
||||||
schedule:
|
|
||||||
- cron: '0 3 * * 0'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
call-codeQL-analysis:
|
|
||||||
name: CodeQL analysis
|
|
||||||
uses: actions/reusable-workflows/.github/workflows/codeql-analysis.yml@main
|
|
||||||
15
.github/workflows/licensed.yml
vendored
15
.github/workflows/licensed.yml
vendored
@@ -1,15 +0,0 @@
|
|||||||
name: Licensed
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
call-licensed:
|
|
||||||
name: Licensed
|
|
||||||
uses: actions/reusable-workflows/.github/workflows/licensed.yml@main
|
|
||||||
28
.github/workflows/release-new-action-version.yml
vendored
28
.github/workflows/release-new-action-version.yml
vendored
@@ -1,28 +0,0 @@
|
|||||||
name: Release new action version
|
|
||||||
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types: [released]
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
TAG_NAME:
|
|
||||||
description: 'Tag name that the major tag will point to'
|
|
||||||
required: true
|
|
||||||
|
|
||||||
env:
|
|
||||||
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
update_tag:
|
|
||||||
name: Update the major tag to include the ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} changes
|
|
||||||
environment:
|
|
||||||
name: releaseNewActionVersion
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Update the ${{ env.TAG_NAME }} tag
|
|
||||||
uses: actions/publish-action@v0.2.2
|
|
||||||
with:
|
|
||||||
source-tag: ${{ env.TAG_NAME }}
|
|
||||||
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
|
||||||
11
.github/workflows/update-config-files.yml
vendored
11
.github/workflows/update-config-files.yml
vendored
@@ -1,11 +0,0 @@
|
|||||||
name: Update configuration files
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 3 * * 0'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
call-update-configuration-files:
|
|
||||||
name: Update configuration files
|
|
||||||
uses: actions/reusable-workflows/.github/workflows/update-config-files.yml@main
|
|
||||||
32
.github/workflows/update_license_cache.yml
vendored
Normal file
32
.github/workflows/update_license_cache.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Updates our cache of license files in response to changes to our dependencies
|
||||||
|
# declared in package-lock.json. Automatically commits the changes and pushes
|
||||||
|
# them to your branch. NB `check_license_status` should always run *after* this
|
||||||
|
#
|
||||||
|
# see https://github.com/actions/labeler/pull/155 for more context
|
||||||
|
|
||||||
|
name: Update License Cache
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths: [package-lock.json]
|
||||||
|
pull_request:
|
||||||
|
branches: main
|
||||||
|
paths: package-lock.json
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update_licenses_cache:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Update License Cache
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- uses: jonabc/setup-licensed@v1
|
||||||
|
with:
|
||||||
|
version: '2.x'
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- run: npm install --production
|
||||||
|
- uses: jonabc/licensed-ci@v1
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
2
.licenses/npm/@actions/core.dep.yml
generated
2
.licenses/npm/@actions/core.dep.yml
generated
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@actions/core"
|
name: "@actions/core"
|
||||||
version: 1.10.0
|
version: 1.4.0
|
||||||
type: npm
|
type: npm
|
||||||
summary: Actions core lib
|
summary: Actions core lib
|
||||||
homepage: https://github.com/actions/toolkit/tree/main/packages/core
|
homepage: https://github.com/actions/toolkit/tree/main/packages/core
|
||||||
|
|||||||
2
.licenses/npm/@actions/github.dep.yml
generated
2
.licenses/npm/@actions/github.dep.yml
generated
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@actions/github"
|
name: "@actions/github"
|
||||||
version: 5.1.1
|
version: 5.0.0
|
||||||
type: npm
|
type: npm
|
||||||
summary: Actions github lib
|
summary: Actions github lib
|
||||||
homepage: https://github.com/actions/toolkit/tree/main/packages/github
|
homepage: https://github.com/actions/toolkit/tree/main/packages/github
|
||||||
|
|||||||
4
.licenses/npm/@actions/http-client.dep.yml
generated
4
.licenses/npm/@actions/http-client.dep.yml
generated
@@ -1,9 +1,9 @@
|
|||||||
---
|
---
|
||||||
name: "@actions/http-client"
|
name: "@actions/http-client"
|
||||||
version: 2.0.1
|
version: 1.0.11
|
||||||
type: npm
|
type: npm
|
||||||
summary: Actions Http Client
|
summary: Actions Http Client
|
||||||
homepage: https://github.com/actions/toolkit/tree/main/packages/http-client
|
homepage: https://github.com/actions/http-client#readme
|
||||||
license: mit
|
license: mit
|
||||||
licenses:
|
licenses:
|
||||||
- sources: LICENSE
|
- sources: LICENSE
|
||||||
|
|||||||
4
.licenses/npm/@octokit/auth-token.dep.yml
generated
4
.licenses/npm/@octokit/auth-token.dep.yml
generated
@@ -1,9 +1,9 @@
|
|||||||
---
|
---
|
||||||
name: "@octokit/auth-token"
|
name: "@octokit/auth-token"
|
||||||
version: 2.5.0
|
version: 2.4.5
|
||||||
type: npm
|
type: npm
|
||||||
summary: GitHub API token authentication for browsers and Node.js
|
summary: GitHub API token authentication for browsers and Node.js
|
||||||
homepage:
|
homepage: https://github.com/octokit/auth-token.js#readme
|
||||||
license: mit
|
license: mit
|
||||||
licenses:
|
licenses:
|
||||||
- sources: LICENSE
|
- sources: LICENSE
|
||||||
|
|||||||
2
.licenses/npm/@octokit/core.dep.yml
generated
2
.licenses/npm/@octokit/core.dep.yml
generated
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@octokit/core"
|
name: "@octokit/core"
|
||||||
version: 3.6.0
|
version: 3.5.1
|
||||||
type: npm
|
type: npm
|
||||||
summary: Extendable client for GitHub's REST & GraphQL APIs
|
summary: Extendable client for GitHub's REST & GraphQL APIs
|
||||||
homepage:
|
homepage:
|
||||||
|
|||||||
2
.licenses/npm/@octokit/graphql.dep.yml
generated
2
.licenses/npm/@octokit/graphql.dep.yml
generated
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@octokit/graphql"
|
name: "@octokit/graphql"
|
||||||
version: 4.8.0
|
version: 4.6.4
|
||||||
type: npm
|
type: npm
|
||||||
summary: GitHub GraphQL API client for browsers and Node
|
summary: GitHub GraphQL API client for browsers and Node
|
||||||
homepage:
|
homepage:
|
||||||
|
|||||||
4
.licenses/npm/@octokit/openapi-types.dep.yml
generated
4
.licenses/npm/@octokit/openapi-types.dep.yml
generated
@@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
name: "@octokit/openapi-types"
|
name: "@octokit/openapi-types"
|
||||||
version: 12.11.0
|
version: 7.3.2
|
||||||
type: npm
|
type: npm
|
||||||
summary: Generated TypeScript definitions based on GitHub's OpenAPI spec for api.github.com
|
summary: Generated TypeScript definitions based on GitHub's OpenAPI spec
|
||||||
homepage:
|
homepage:
|
||||||
license: mit
|
license: mit
|
||||||
licenses:
|
licenses:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@octokit/plugin-paginate-rest"
|
name: "@octokit/plugin-paginate-rest"
|
||||||
version: 2.21.3
|
version: 2.13.5
|
||||||
type: npm
|
type: npm
|
||||||
summary: Octokit plugin to paginate REST API endpoint responses
|
summary: Octokit plugin to paginate REST API endpoint responses
|
||||||
homepage:
|
homepage:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@octokit/plugin-rest-endpoint-methods"
|
name: "@octokit/plugin-rest-endpoint-methods"
|
||||||
version: 5.16.2
|
version: 5.3.1
|
||||||
type: npm
|
type: npm
|
||||||
summary: Octokit plugin adding one method for all of api.github.com REST API endpoints
|
summary: Octokit plugin adding one method for all of api.github.com REST API endpoints
|
||||||
homepage:
|
homepage:
|
||||||
|
|||||||
6
.licenses/npm/@octokit/request.dep.yml
generated
6
.licenses/npm/@octokit/request.dep.yml
generated
@@ -1,9 +1,9 @@
|
|||||||
---
|
---
|
||||||
name: "@octokit/request"
|
name: "@octokit/request"
|
||||||
version: 5.6.3
|
version: 5.6.0
|
||||||
type: npm
|
type: npm
|
||||||
summary: Send parameterized requests to GitHub's APIs with sensible defaults in browsers
|
summary: "Send parameterized requests to GitHubâ\x80\x99s APIs with sensible defaults
|
||||||
and Node
|
in browsers and Node"
|
||||||
homepage:
|
homepage:
|
||||||
license: mit
|
license: mit
|
||||||
licenses:
|
licenses:
|
||||||
|
|||||||
2
.licenses/npm/@octokit/types.dep.yml
generated
2
.licenses/npm/@octokit/types.dep.yml
generated
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@octokit/types"
|
name: "@octokit/types"
|
||||||
version: 6.41.0
|
version: 6.16.4
|
||||||
type: npm
|
type: npm
|
||||||
summary: Shared TypeScript definitions for Octokit projects
|
summary: Shared TypeScript definitions for Octokit projects
|
||||||
homepage:
|
homepage:
|
||||||
|
|||||||
2
.licenses/npm/balanced-match.dep.yml
generated
2
.licenses/npm/balanced-match.dep.yml
generated
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: balanced-match
|
name: balanced-match
|
||||||
version: 1.0.2
|
version: 1.0.0
|
||||||
type: npm
|
type: npm
|
||||||
summary: Match balanced character pairs, like "{" and "}"
|
summary: Match balanced character pairs, like "{" and "}"
|
||||||
homepage: https://github.com/juliangruber/balanced-match
|
homepage: https://github.com/juliangruber/balanced-match
|
||||||
|
|||||||
2
.licenses/npm/before-after-hook.dep.yml
generated
2
.licenses/npm/before-after-hook.dep.yml
generated
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: before-after-hook
|
name: before-after-hook
|
||||||
version: 2.2.3
|
version: 2.2.2
|
||||||
type: npm
|
type: npm
|
||||||
summary: asynchronous before/error/after hooks for internal functionality
|
summary: asynchronous before/error/after hooks for internal functionality
|
||||||
homepage:
|
homepage:
|
||||||
|
|||||||
2
.licenses/npm/brace-expansion.dep.yml
generated
2
.licenses/npm/brace-expansion.dep.yml
generated
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: brace-expansion
|
name: brace-expansion
|
||||||
version: 2.0.1
|
version: 1.1.11
|
||||||
type: npm
|
type: npm
|
||||||
summary: Brace expansion as known from sh/bash
|
summary: Brace expansion as known from sh/bash
|
||||||
homepage: https://github.com/juliangruber/brace-expansion
|
homepage: https://github.com/juliangruber/brace-expansion
|
||||||
|
|||||||
31
.licenses/npm/concat-map.dep.yml
generated
Normal file
31
.licenses/npm/concat-map.dep.yml
generated
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
name: concat-map
|
||||||
|
version: 0.0.1
|
||||||
|
type: npm
|
||||||
|
summary: concatenative mapdashery
|
||||||
|
homepage:
|
||||||
|
license: other
|
||||||
|
licenses:
|
||||||
|
- sources: LICENSE
|
||||||
|
text: |
|
||||||
|
This software is released under the MIT license:
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
- sources: README.markdown
|
||||||
|
text: MIT
|
||||||
|
notices: []
|
||||||
4
.licenses/npm/minimatch.dep.yml
generated
4
.licenses/npm/minimatch.dep.yml
generated
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: minimatch
|
name: minimatch
|
||||||
version: 7.4.3
|
version: 3.0.4
|
||||||
type: npm
|
type: npm
|
||||||
summary: a glob matcher in javascript
|
summary: a glob matcher in javascript
|
||||||
homepage:
|
homepage:
|
||||||
@@ -10,7 +10,7 @@ licenses:
|
|||||||
text: |
|
text: |
|
||||||
The ISC License
|
The ISC License
|
||||||
|
|
||||||
Copyright (c) 2011-2022 Isaac Z. Schlueter and Contributors
|
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|||||||
2
.licenses/npm/node-fetch.dep.yml
generated
2
.licenses/npm/node-fetch.dep.yml
generated
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: node-fetch
|
name: node-fetch
|
||||||
version: 2.6.7
|
version: 2.6.1
|
||||||
type: npm
|
type: npm
|
||||||
summary: A light-weight module that brings window.fetch to node.js
|
summary: A light-weight module that brings window.fetch to node.js
|
||||||
homepage: https://github.com/bitinn/node-fetch
|
homepage: https://github.com/bitinn/node-fetch
|
||||||
|
|||||||
30
.licenses/npm/tr46.dep.yml
generated
30
.licenses/npm/tr46.dep.yml
generated
@@ -1,30 +0,0 @@
|
|||||||
---
|
|
||||||
name: tr46
|
|
||||||
version: 0.0.3
|
|
||||||
type: npm
|
|
||||||
summary: An implementation of the Unicode TR46 spec
|
|
||||||
homepage: https://github.com/Sebmaster/tr46.js#readme
|
|
||||||
license: mit
|
|
||||||
licenses:
|
|
||||||
- sources: Auto-generated MIT license text
|
|
||||||
text: |
|
|
||||||
MIT License
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
notices: []
|
|
||||||
20
.licenses/npm/uuid.dep.yml
generated
20
.licenses/npm/uuid.dep.yml
generated
@@ -1,20 +0,0 @@
|
|||||||
---
|
|
||||||
name: uuid
|
|
||||||
version: 8.3.2
|
|
||||||
type: npm
|
|
||||||
summary: RFC4122 (v1, v4, and v5) UUIDs
|
|
||||||
homepage:
|
|
||||||
license: mit
|
|
||||||
licenses:
|
|
||||||
- sources: LICENSE.md
|
|
||||||
text: |
|
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2010-2020 Robert Kieffer and other contributors
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
notices: []
|
|
||||||
23
.licenses/npm/webidl-conversions.dep.yml
generated
23
.licenses/npm/webidl-conversions.dep.yml
generated
@@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
name: webidl-conversions
|
|
||||||
version: 3.0.1
|
|
||||||
type: npm
|
|
||||||
summary: Implements the WebIDL algorithms for converting to and from JavaScript values
|
|
||||||
homepage:
|
|
||||||
license: bsd-2-clause
|
|
||||||
licenses:
|
|
||||||
- sources: LICENSE.md
|
|
||||||
text: |
|
|
||||||
# The BSD 2-Clause License
|
|
||||||
|
|
||||||
Copyright (c) 2014, Domenic Denicola
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
notices: []
|
|
||||||
32
.licenses/npm/whatwg-url.dep.yml
generated
32
.licenses/npm/whatwg-url.dep.yml
generated
@@ -1,32 +0,0 @@
|
|||||||
---
|
|
||||||
name: whatwg-url
|
|
||||||
version: 5.0.0
|
|
||||||
type: npm
|
|
||||||
summary: An implementation of the WHATWG URL Standard's URL API and parsing machinery
|
|
||||||
homepage:
|
|
||||||
license: mit
|
|
||||||
licenses:
|
|
||||||
- sources: LICENSE.txt
|
|
||||||
text: |
|
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2015–2016 Sebastian Mayr
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
notices: []
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
# Ignore list
|
|
||||||
/*
|
|
||||||
|
|
||||||
# Do not ignore these folders:
|
|
||||||
!__tests__/
|
|
||||||
!__mocks__/
|
|
||||||
!.github/
|
|
||||||
!src/
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
// This is a reusable configuration file copied from https://github.com/actions/reusable-workflows/tree/main/reusable-configurations. Please don't make changes to this file as it's the subject of an automatic update.
|
|
||||||
module.exports = {
|
|
||||||
printWidth: 80,
|
|
||||||
tabWidth: 2,
|
|
||||||
useTabs: false,
|
|
||||||
semi: true,
|
|
||||||
singleQuote: true,
|
|
||||||
trailingComma: 'none',
|
|
||||||
bracketSpacing: false,
|
|
||||||
arrowParens: 'avoid'
|
|
||||||
};
|
|
||||||
@@ -1 +1 @@
|
|||||||
* @actions/setup-actions-team
|
* @actions/actions-runtime
|
||||||
|
|||||||
112
README.md
112
README.md
@@ -1,84 +1,61 @@
|
|||||||
# Pull Request Labeler
|
# Pull Request Labeler
|
||||||
|
|
||||||
[](https://github.com/actions/labeler/actions/workflows/basic-validation.yml)
|
<p align="left">
|
||||||
|
<a href="https://github.com/actions/labeler/actions?query=workflow%3A%22Build+%26+Test%22++">
|
||||||
|
<img alt="build and test status" src="https://github.com/actions/labeler/actions/workflows/build_test.yml/badge.svg">
|
||||||
|
</a>
|
||||||
|
<a href="https://david-dm.org/actions/labeler">
|
||||||
|
<img alt="dependencies" src="https://status.david-dm.org/gh/actions/labeler.svg">
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
Automatically label new pull requests based on the paths of files being changed or the branch name.
|
Automatically label new pull requests based on the paths of files being changed.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Create `.github/labeler.yml`
|
### Create `.github/labeler.yml`
|
||||||
|
|
||||||
Create a `.github/labeler.yml` file with a list of labels and config options to match and apply the label.
|
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 a match object.
|
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`) or a match object.
|
||||||
|
|
||||||
#### Match Object
|
#### Match Object
|
||||||
|
|
||||||
The match object allows control over the matching options, you can specify the label to be applied based on the files that have changed or the name of either the base branch or the head branch. For the changed files options you provide a [path glob](https://github.com/isaacs/minimatch#minimatch), and for the branches you provide a regexp to match against the branch name.
|
For more control over matching, you can provide a match object instead of a simple path glob. The match object is defined as:
|
||||||
|
|
||||||
The base match object is defined as:
|
|
||||||
```yml
|
```yml
|
||||||
- changed-files: ['list', 'of', 'globs']
|
- any: ['list', 'of', 'globs']
|
||||||
- base-branch: ['list', 'of', 'regexps']
|
all: ['list', 'of', 'globs']
|
||||||
- head-branch: ['list', 'of', 'regexps']
|
|
||||||
```
|
```
|
||||||
|
|
||||||
There are two top level keys of `any` and `all`, which both accept the same config options:
|
One or both fields can be provided for fine-grained matching. Unlike the top-level list, the list of path globs provided to `any` and `all` must ALL match against a path for the label to be applied.
|
||||||
```yml
|
|
||||||
- any:
|
|
||||||
- changed-files: ['list', 'of', 'globs']
|
|
||||||
- base-branch: ['list', 'of', 'regexps']
|
|
||||||
- head-branch: ['list', 'of', 'regexps']
|
|
||||||
- all:
|
|
||||||
- changed-files: ['list', 'of', 'globs']
|
|
||||||
- base-branch: ['list', 'of', 'regexps']
|
|
||||||
- head-branch: ['list', 'of', 'regexps']
|
|
||||||
```
|
|
||||||
|
|
||||||
One or all fields can be provided for fine-grained matching.
|
|
||||||
The fields are defined as follows:
|
The fields are defined as follows:
|
||||||
* `all`: all of the provided options must match in order for the label to be applied
|
* `any`: match ALL globs against ANY changed path
|
||||||
* `any`: if any of the provided options match then a label will be applied
|
* `all`: match ALL globs against ALL changed paths
|
||||||
* `base-branch`: match regexps against the base branch name
|
|
||||||
* `changed-files`: match glob patterns against the changed paths
|
|
||||||
* `head-branch`: match regexps against the head branch name
|
|
||||||
|
|
||||||
If a base option is provided without a top-level key then it will default to `any`. More specifically, the following two configurations are equivalent:
|
A simple path glob is the equivalent to `any: ['glob']`. More specifically, the following two configurations are equivalent:
|
||||||
```yml
|
```yml
|
||||||
label1:
|
label1:
|
||||||
- changed-files: example1/*
|
- example1/*
|
||||||
```
|
```
|
||||||
and
|
and
|
||||||
```yml
|
```yml
|
||||||
label1:
|
label1:
|
||||||
- any:
|
- any: ['example1/*']
|
||||||
- changed-files: ['example1/*']
|
|
||||||
```
|
```
|
||||||
|
|
||||||
From a boolean logic perspective, top-level match objects, and options within `all` are `AND`-ed together and individual match rules within the `any` object are `OR`-ed. If path globs are combined with `!` negation, you can write complex matching rules.
|
From a boolean logic perspective, top-level match objects are `OR`-ed together and individual match rules within an object are `AND`-ed. Combined with `!` negation, you can write complex matching rules.
|
||||||
|
|
||||||
#### Basic Examples
|
#### Basic Examples
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
# Add 'label1' to any changes within 'example' folder or any subfolders
|
# Add 'label1' to any changes within 'example' folder or any subfolders
|
||||||
label1:
|
label1:
|
||||||
- changed-files: example/**/*
|
- example/**/*
|
||||||
|
|
||||||
# Add 'label2' to any file changes within 'example2' folder
|
# Add 'label2' to any file changes within 'example2' folder
|
||||||
label2:
|
label2: example2/*
|
||||||
- changed-files: example2/*
|
|
||||||
|
|
||||||
# Add label3 to any change to .txt files within the entire repository. Quotation marks are required for the leading asterisk
|
|
||||||
label3:
|
|
||||||
- changed-files: '**/*.txt'
|
|
||||||
|
|
||||||
# Add 'label4' to any PR where the head branch name starts with 'example4'
|
|
||||||
label4:
|
|
||||||
- head-branch: '^example4'
|
|
||||||
|
|
||||||
# Add 'label5' to any PR where the base branch name starts with 'example5'
|
|
||||||
label5:
|
|
||||||
- base-branch: '^example5'
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Common Examples
|
#### Common Examples
|
||||||
@@ -86,67 +63,56 @@ label5:
|
|||||||
```yml
|
```yml
|
||||||
# Add 'repo' label to any root file changes
|
# Add 'repo' label to any root file changes
|
||||||
repo:
|
repo:
|
||||||
- changed-files: '*'
|
- ./*
|
||||||
|
|
||||||
# Add '@domain/core' label to any change within the 'core' package
|
# Add '@domain/core' label to any change within the 'core' package
|
||||||
'@domain/core':
|
@domain/core:
|
||||||
- changed-files:
|
- package/core/*
|
||||||
- package/core/*
|
- package/core/**/*
|
||||||
- package/core/**/*
|
|
||||||
|
|
||||||
# Add 'test' label to any change to *.spec.js files within the source dir
|
# Add 'test' label to any change to *.spec.js files within the source dir
|
||||||
test:
|
test:
|
||||||
- changed-files: src/**/*.spec.js
|
- src/**/*.spec.js
|
||||||
|
|
||||||
# Add 'source' label to any change to src files within the source dir EXCEPT for the docs sub-folder
|
# Add 'source' label to any change to src files within the source dir EXCEPT for the docs sub-folder
|
||||||
source:
|
source:
|
||||||
- changed-files:
|
- any: ['src/**/*', '!src/docs/*']
|
||||||
- any: ['src/**/*', '!src/docs/*']
|
|
||||||
|
|
||||||
# Add 'frontend` label to any change to *.js files as long as the `main.js` hasn't changed
|
# Add 'frontend` label to any change to *.js files as long as the `main.js` hasn't changed
|
||||||
frontend:
|
frontend:
|
||||||
- any:
|
- any: ['src/**/*.js']
|
||||||
- changed-files: ['src/**/*.js']
|
all: ['!src/main.js']
|
||||||
- all:
|
|
||||||
- changed-files: ['!src/main.js']
|
|
||||||
|
|
||||||
# Add 'feature' label to any PR where the head branch name starts with `feature` or has a `feature` section in the name
|
|
||||||
feature:
|
|
||||||
- head-branch: ['^feature', 'feature']
|
|
||||||
|
|
||||||
# Add 'release' label to any PR that is opened against the `main` branch
|
|
||||||
release:
|
|
||||||
- base-branch: 'main'
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Create Workflow
|
### 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:
|
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:
|
||||||
|
|
||||||
```yml
|
```
|
||||||
name: "Pull Request Labeler"
|
name: "Pull Request Labeler"
|
||||||
on:
|
on:
|
||||||
- pull_request_target
|
- pull_request_target
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
triage:
|
triage:
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
pull-requests: write
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/labeler@v5
|
- uses: actions/labeler@v3
|
||||||
|
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_
|
||||||
|
|
||||||
#### Inputs
|
#### Inputs
|
||||||
|
|
||||||
Various inputs are defined in [`action.yml`](action.yml) to let you configure the labeler:
|
Various inputs are defined in [`action.yml`](action.yml) to let you configure the labeler:
|
||||||
|
|
||||||
| Name | Description | Default |
|
| Name | Description | Default |
|
||||||
| - | - | - |
|
| - | - | - |
|
||||||
| `repo-token` | Token to use to authorize label changes. Typically the GITHUB_TOKEN secret, with `contents:read` and `pull-requests:write` access | `github.token` |
|
| `repo-token` | Token to use to authorize label changes. Typically the GITHUB_TOKEN secret | N/A |
|
||||||
| `configuration-path` | The path to the label configuration file | `.github/labeler.yml` |
|
| `configuration-path` | The path to the label configuration file | `.github/labeler.yml` |
|
||||||
| `sync-labels` | Whether or not to remove labels when matching files are reverted or no longer changed by the PR | `false`|
|
| `sync-labels` | Whether or not to remove labels when matching files are reverted or no longer changed by the PR | `false`
|
||||||
|
|
||||||
# Contributions
|
# Contributions
|
||||||
|
|
||||||
|
|||||||
@@ -2,39 +2,33 @@ export const context = {
|
|||||||
payload: {
|
payload: {
|
||||||
pull_request: {
|
pull_request: {
|
||||||
number: 123,
|
number: 123,
|
||||||
head: {
|
},
|
||||||
ref: 'head-branch-name'
|
|
||||||
},
|
|
||||||
base: {
|
|
||||||
ref: 'base-branch-name'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
repo: {
|
repo: {
|
||||||
owner: 'monalisa',
|
owner: "monalisa",
|
||||||
repo: 'helloworld'
|
repo: "helloworld",
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockApi = {
|
const mockApi = {
|
||||||
rest: {
|
rest: {
|
||||||
issues: {
|
issues: {
|
||||||
addLabels: jest.fn(),
|
addLabels: jest.fn(),
|
||||||
removeLabel: jest.fn()
|
removeLabel: jest.fn(),
|
||||||
},
|
},
|
||||||
pulls: {
|
pulls: {
|
||||||
get: jest.fn().mockResolvedValue({}),
|
get: jest.fn().mockResolvedValue({}),
|
||||||
listFiles: {
|
listFiles: {
|
||||||
endpoint: {
|
endpoint: {
|
||||||
merge: jest.fn().mockReturnValue({})
|
merge: jest.fn().mockReturnValue({}),
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
repos: {
|
repos: {
|
||||||
getContent: jest.fn()
|
getContent: jest.fn(),
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
paginate: jest.fn()
|
paginate: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getOctokit = jest.fn().mockImplementation(() => mockApi);
|
export const getOctokit = jest.fn().mockImplementation(() => mockApi);
|
||||||
|
|||||||
@@ -1,210 +0,0 @@
|
|||||||
import {
|
|
||||||
getBranchName,
|
|
||||||
checkAnyBranch,
|
|
||||||
checkAllBranch,
|
|
||||||
toBranchMatchConfig,
|
|
||||||
BranchMatchConfig
|
|
||||||
} from '../src/branch';
|
|
||||||
import * as github from '@actions/github';
|
|
||||||
|
|
||||||
jest.mock('@actions/core');
|
|
||||||
jest.mock('@actions/github');
|
|
||||||
|
|
||||||
describe('getBranchName', () => {
|
|
||||||
describe('when the pull requests base branch is requested', () => {
|
|
||||||
it('returns the base branch name', () => {
|
|
||||||
const result = getBranchName('base');
|
|
||||||
expect(result).toEqual('base-branch-name');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when the pull requests head branch is requested', () => {
|
|
||||||
it('returns the head branch name', () => {
|
|
||||||
const result = getBranchName('head');
|
|
||||||
expect(result).toEqual('head-branch-name');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('checkAllBranch', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
github.context.payload.pull_request!.head = {
|
|
||||||
ref: 'test/feature/123'
|
|
||||||
};
|
|
||||||
github.context.payload.pull_request!.base = {
|
|
||||||
ref: 'main'
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when a single pattern is provided', () => {
|
|
||||||
describe('and the pattern matches the head branch', () => {
|
|
||||||
it('returns true', () => {
|
|
||||||
const result = checkAllBranch(['^test'], 'head');
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('and the pattern does not match the head branch', () => {
|
|
||||||
it('returns false', () => {
|
|
||||||
const result = checkAllBranch(['^feature/'], 'head');
|
|
||||||
expect(result).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when multiple patterns are provided', () => {
|
|
||||||
describe('and not all patterns matched', () => {
|
|
||||||
it('returns false', () => {
|
|
||||||
const result = checkAllBranch(['^test/', '^feature/'], 'head');
|
|
||||||
expect(result).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('and all patterns match', () => {
|
|
||||||
it('returns true', () => {
|
|
||||||
const result = checkAllBranch(['^test/', '/feature/'], 'head');
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('and no patterns match', () => {
|
|
||||||
it('returns false', () => {
|
|
||||||
const result = checkAllBranch(['^feature/', '/test$'], 'head');
|
|
||||||
expect(result).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when the branch to check is specified as the base branch', () => {
|
|
||||||
describe('and the pattern matches the base branch', () => {
|
|
||||||
it('returns true', () => {
|
|
||||||
const result = checkAllBranch(['^main$'], 'base');
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('checkAnyBranch', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
github.context.payload.pull_request!.head = {
|
|
||||||
ref: 'test/feature/123'
|
|
||||||
};
|
|
||||||
github.context.payload.pull_request!.base = {
|
|
||||||
ref: 'main'
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when a single pattern is provided', () => {
|
|
||||||
describe('and the pattern matches the head branch', () => {
|
|
||||||
it('returns true', () => {
|
|
||||||
const result = checkAnyBranch(['^test'], 'head');
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('and the pattern does not match the head branch', () => {
|
|
||||||
it('returns false', () => {
|
|
||||||
const result = checkAnyBranch(['^feature/'], 'head');
|
|
||||||
expect(result).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when multiple patterns are provided', () => {
|
|
||||||
describe('and at least one pattern matches', () => {
|
|
||||||
it('returns true', () => {
|
|
||||||
const result = checkAnyBranch(['^test/', '^feature/'], 'head');
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('and all patterns match', () => {
|
|
||||||
it('returns true', () => {
|
|
||||||
const result = checkAnyBranch(['^test/', '/feature/'], 'head');
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('and no patterns match', () => {
|
|
||||||
it('returns false', () => {
|
|
||||||
const result = checkAnyBranch(['^feature/', '/test$'], 'head');
|
|
||||||
expect(result).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when the branch to check is specified as the base branch', () => {
|
|
||||||
describe('and the pattern matches the base branch', () => {
|
|
||||||
it('returns true', () => {
|
|
||||||
const result = checkAnyBranch(['^main$'], 'base');
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('toBranchMatchConfig', () => {
|
|
||||||
describe('when there are no branch keys in the config', () => {
|
|
||||||
const config = {'changed-files': [{any: ['testing']}]};
|
|
||||||
|
|
||||||
it('returns an empty object', () => {
|
|
||||||
const result = toBranchMatchConfig(config);
|
|
||||||
expect(result).toEqual({});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when the config contains a head-branch option', () => {
|
|
||||||
const config = {'head-branch': ['testing']};
|
|
||||||
|
|
||||||
it('sets headBranch in the matchConfig', () => {
|
|
||||||
const result = toBranchMatchConfig(config);
|
|
||||||
expect(result).toEqual<BranchMatchConfig>({
|
|
||||||
headBranch: ['testing']
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('and the matching option is a string', () => {
|
|
||||||
const stringConfig = {'head-branch': 'testing'};
|
|
||||||
|
|
||||||
it('sets headBranch in the matchConfig', () => {
|
|
||||||
const result = toBranchMatchConfig(stringConfig);
|
|
||||||
expect(result).toEqual<BranchMatchConfig>({
|
|
||||||
headBranch: ['testing']
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when the config contains a base-branch option', () => {
|
|
||||||
const config = {'base-branch': ['testing']};
|
|
||||||
it('sets baseBranch in the matchConfig', () => {
|
|
||||||
const result = toBranchMatchConfig(config);
|
|
||||||
expect(result).toEqual<BranchMatchConfig>({
|
|
||||||
baseBranch: ['testing']
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('and the matching option is a string', () => {
|
|
||||||
const stringConfig = {'base-branch': 'testing'};
|
|
||||||
|
|
||||||
it('sets baseBranch in the matchConfig', () => {
|
|
||||||
const result = toBranchMatchConfig(stringConfig);
|
|
||||||
expect(result).toEqual<BranchMatchConfig>({
|
|
||||||
baseBranch: ['testing']
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when the config contains both a base-branch and head-branch option', () => {
|
|
||||||
const config = {'base-branch': ['testing'], 'head-branch': ['testing']};
|
|
||||||
it('sets headBranch and baseBranch in the matchConfig', () => {
|
|
||||||
const result = toBranchMatchConfig(config);
|
|
||||||
expect(result).toEqual<BranchMatchConfig>({
|
|
||||||
baseBranch: ['testing'],
|
|
||||||
headBranch: ['testing']
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
import {
|
|
||||||
ChangedFilesMatchConfig,
|
|
||||||
checkAllChangedFiles,
|
|
||||||
checkAnyChangedFiles,
|
|
||||||
toChangedFilesMatchConfig
|
|
||||||
} from '../src/changedFiles';
|
|
||||||
|
|
||||||
jest.mock('@actions/core');
|
|
||||||
jest.mock('@actions/github');
|
|
||||||
|
|
||||||
describe('checkAllChangedFiles', () => {
|
|
||||||
const changedFiles = ['foo.txt', 'bar.txt'];
|
|
||||||
|
|
||||||
describe('when the globs match every file that has been changed', () => {
|
|
||||||
const globs = ['*.txt'];
|
|
||||||
|
|
||||||
it('returns true', () => {
|
|
||||||
const result = checkAllChangedFiles(changedFiles, globs);
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe(`when the globs don't match every file that has changed`, () => {
|
|
||||||
const globs = ['foo.txt'];
|
|
||||||
|
|
||||||
it('returns false', () => {
|
|
||||||
const result = checkAllChangedFiles(changedFiles, globs);
|
|
||||||
expect(result).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('checkAnyChangedFiles', () => {
|
|
||||||
const changedFiles = ['foo.txt', 'bar.txt'];
|
|
||||||
|
|
||||||
describe('when any glob matches any of the files that have changed', () => {
|
|
||||||
const globs = ['*.txt', '*.md'];
|
|
||||||
|
|
||||||
it('returns true', () => {
|
|
||||||
const result = checkAnyChangedFiles(changedFiles, globs);
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when none of the globs match any files that have changed', () => {
|
|
||||||
const globs = ['*.md'];
|
|
||||||
|
|
||||||
it('returns false', () => {
|
|
||||||
const result = checkAnyChangedFiles(changedFiles, globs);
|
|
||||||
expect(result).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('toChangedFilesMatchConfig', () => {
|
|
||||||
describe(`when there is no 'changed-files' key in the config`, () => {
|
|
||||||
const config = {'head-branch': 'test'};
|
|
||||||
|
|
||||||
it('returns an empty object', () => {
|
|
||||||
const result = toChangedFilesMatchConfig(config);
|
|
||||||
expect(result).toEqual<ChangedFilesMatchConfig>({});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe(`when there is a 'changed-files' key in the config`, () => {
|
|
||||||
describe('and the value is an array of strings', () => {
|
|
||||||
const config = {'changed-files': ['testing']};
|
|
||||||
|
|
||||||
it('sets the value in the config object', () => {
|
|
||||||
const result = toChangedFilesMatchConfig(config);
|
|
||||||
expect(result).toEqual<ChangedFilesMatchConfig>({
|
|
||||||
changedFiles: ['testing']
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('and the value is a string', () => {
|
|
||||||
const config = {'changed-files': 'testing'};
|
|
||||||
|
|
||||||
it(`sets the string as an array in the config object`, () => {
|
|
||||||
const result = toChangedFilesMatchConfig(config);
|
|
||||||
expect(result).toEqual<ChangedFilesMatchConfig>({
|
|
||||||
changedFiles: ['testing']
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('but the value is an empty string', () => {
|
|
||||||
const config = {'changed-files': ''};
|
|
||||||
|
|
||||||
it(`returns an empty object`, () => {
|
|
||||||
const result = toChangedFilesMatchConfig(config);
|
|
||||||
expect(result).toEqual<ChangedFilesMatchConfig>({});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('but the value is an empty array', () => {
|
|
||||||
const config = {'changed-files': []};
|
|
||||||
|
|
||||||
it(`returns an empty object`, () => {
|
|
||||||
const result = toChangedFilesMatchConfig(config);
|
|
||||||
expect(result).toEqual<ChangedFilesMatchConfig>({});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
label1:
|
|
||||||
- any:
|
|
||||||
- changed-files: ['glob']
|
|
||||||
- head-branch: ['regexp']
|
|
||||||
- base-branch: ['regexp']
|
|
||||||
- all:
|
|
||||||
- changed-files: ['glob']
|
|
||||||
- head-branch: ['regexp']
|
|
||||||
- base-branch: ['regexp']
|
|
||||||
|
|
||||||
label2:
|
|
||||||
- changed-files: ['glob']
|
|
||||||
- head-branch: ['regexp']
|
|
||||||
- base-branch: ['regexp']
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
tests:
|
|
||||||
- any:
|
|
||||||
- head-branch: ['^tests/', '^test/']
|
|
||||||
- changed-files: ['tests/**/*']
|
|
||||||
- all:
|
|
||||||
- changed-files: ['!tests/requirements.txt']
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
test-branch:
|
|
||||||
- head-branch: '^test/'
|
|
||||||
|
|
||||||
feature-branch:
|
|
||||||
- head-branch: '/feature/'
|
|
||||||
|
|
||||||
bug-branch:
|
|
||||||
- head-branch: '^bug/|fix/'
|
|
||||||
|
|
||||||
array-branch:
|
|
||||||
- head-branch: ['^array/']
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
label:
|
|
||||||
- all:
|
|
||||||
- unknown: 'this-is-not-supported'
|
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
touched-a-pdf-file:
|
touched-a-pdf-file:
|
||||||
- changed-files: ['*.pdf']
|
- any: ['*.pdf']
|
||||||
|
|||||||
@@ -1,140 +1,29 @@
|
|||||||
import {
|
import { checkGlobs } from "../src/labeler";
|
||||||
checkMatchConfigs,
|
|
||||||
MatchConfig,
|
|
||||||
toMatchConfig,
|
|
||||||
getLabelConfigMapFromObject,
|
|
||||||
BaseMatchConfig
|
|
||||||
} from '../src/labeler';
|
|
||||||
import * as yaml from 'js-yaml';
|
|
||||||
import * as core from '@actions/core';
|
|
||||||
import * as fs from 'fs';
|
|
||||||
|
|
||||||
jest.mock('@actions/core');
|
import * as core from "@actions/core";
|
||||||
|
|
||||||
|
jest.mock("@actions/core");
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
jest.spyOn(core, 'getInput').mockImplementation((name, options) => {
|
jest.spyOn(core, "getInput").mockImplementation((name, options) => {
|
||||||
return jest.requireActual('@actions/core').getInput(name, options);
|
return jest.requireActual("@actions/core").getInput(name, options);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const loadYaml = (filepath: string) => {
|
const matchConfig = [{ any: ["*.txt"] }];
|
||||||
const loadedFile = fs.readFileSync(filepath);
|
|
||||||
const content = Buffer.from(loadedFile).toString();
|
|
||||||
return yaml.load(content);
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('getLabelConfigMapFromObject', () => {
|
describe("checkGlobs", () => {
|
||||||
const yamlObject = loadYaml('__tests__/fixtures/all_options.yml');
|
it("returns true when our pattern does match changed files", () => {
|
||||||
const expected = new Map<string, MatchConfig[]>();
|
const changedFiles = ["foo.txt", "bar.txt"];
|
||||||
expected.set('label1', [
|
const result = checkGlobs(changedFiles, matchConfig);
|
||||||
{
|
|
||||||
any: [
|
|
||||||
{changedFiles: ['glob']},
|
|
||||||
{baseBranch: undefined, headBranch: ['regexp']},
|
|
||||||
{baseBranch: ['regexp'], headBranch: undefined}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
all: [
|
|
||||||
{changedFiles: ['glob']},
|
|
||||||
{baseBranch: undefined, headBranch: ['regexp']},
|
|
||||||
{baseBranch: ['regexp'], headBranch: undefined}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
expected.set('label2', [
|
|
||||||
{
|
|
||||||
any: [
|
|
||||||
{changedFiles: ['glob']},
|
|
||||||
{baseBranch: undefined, headBranch: ['regexp']},
|
|
||||||
{baseBranch: ['regexp'], headBranch: undefined}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
|
|
||||||
it('returns a MatchConfig', () => {
|
expect(result).toBeTruthy();
|
||||||
const result = getLabelConfigMapFromObject(yamlObject);
|
});
|
||||||
expect(result).toEqual(expected);
|
|
||||||
});
|
it("returns false when our pattern does not match changed files", () => {
|
||||||
});
|
const changedFiles = ["foo.docx"];
|
||||||
|
const result = checkGlobs(changedFiles, matchConfig);
|
||||||
describe('toMatchConfig', () => {
|
|
||||||
describe('when all expected config options are present', () => {
|
expect(result).toBeFalsy();
|
||||||
const config = {
|
|
||||||
'changed-files': ['testing-files'],
|
|
||||||
'head-branch': ['testing-head'],
|
|
||||||
'base-branch': ['testing-base']
|
|
||||||
};
|
|
||||||
const expected: BaseMatchConfig = {
|
|
||||||
changedFiles: ['testing-files'],
|
|
||||||
headBranch: ['testing-head'],
|
|
||||||
baseBranch: ['testing-base']
|
|
||||||
};
|
|
||||||
|
|
||||||
it('returns a MatchConfig object with all options', () => {
|
|
||||||
const result = toMatchConfig(config);
|
|
||||||
expect(result).toEqual(expected);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('and there are also unexpected options present', () => {
|
|
||||||
config['test-test'] = 'testing';
|
|
||||||
|
|
||||||
it('does not include the unexpected items in the returned MatchConfig object', () => {
|
|
||||||
const result = toMatchConfig(config);
|
|
||||||
expect(result).toEqual(expected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('checkMatchConfigs', () => {
|
|
||||||
describe('when a single match config is provided', () => {
|
|
||||||
const matchConfig: MatchConfig[] = [{any: [{changedFiles: ['*.txt']}]}];
|
|
||||||
|
|
||||||
it('returns true when our pattern does match changed files', () => {
|
|
||||||
const changedFiles = ['foo.txt', 'bar.txt'];
|
|
||||||
const result = checkMatchConfigs(changedFiles, matchConfig);
|
|
||||||
|
|
||||||
expect(result).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns false when our pattern does not match changed files', () => {
|
|
||||||
const changedFiles = ['foo.docx'];
|
|
||||||
const result = checkMatchConfigs(changedFiles, matchConfig);
|
|
||||||
|
|
||||||
expect(result).toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns true when either the branch or changed files patter matches', () => {
|
|
||||||
const matchConfig: MatchConfig[] = [
|
|
||||||
{any: [{changedFiles: ['*.txt']}, {headBranch: ['some-branch']}]}
|
|
||||||
];
|
|
||||||
const changedFiles = ['foo.txt', 'bar.txt'];
|
|
||||||
|
|
||||||
const result = checkMatchConfigs(changedFiles, matchConfig);
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when multiple MatchConfigs are supplied', () => {
|
|
||||||
const matchConfig: MatchConfig[] = [
|
|
||||||
{any: [{changedFiles: ['*.txt']}]},
|
|
||||||
{any: [{headBranch: ['some-branch']}]}
|
|
||||||
];
|
|
||||||
const changedFiles = ['foo.txt', 'bar.md'];
|
|
||||||
|
|
||||||
it('returns false when only one config matches', () => {
|
|
||||||
const result = checkMatchConfigs(changedFiles, matchConfig);
|
|
||||||
expect(result).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns true when only both config matches', () => {
|
|
||||||
const matchConfig: MatchConfig[] = [
|
|
||||||
{any: [{changedFiles: ['*.txt']}]},
|
|
||||||
{any: [{headBranch: ['head-branch']}]}
|
|
||||||
];
|
|
||||||
const result = checkMatchConfigs(changedFiles, matchConfig);
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,48 +1,45 @@
|
|||||||
import {run} from '../src/labeler';
|
import { run } from "../src/labeler";
|
||||||
import * as github from '@actions/github';
|
import * as github from "@actions/github";
|
||||||
import * as core from '@actions/core';
|
import * as core from "@actions/core";
|
||||||
|
|
||||||
const fs = jest.requireActual('fs');
|
const fs = jest.requireActual("fs");
|
||||||
|
|
||||||
jest.mock('@actions/core');
|
jest.mock("@actions/core");
|
||||||
jest.mock('@actions/github');
|
jest.mock("@actions/github");
|
||||||
|
|
||||||
const gh = github.getOctokit('_');
|
const gh = github.getOctokit("_");
|
||||||
const addLabelsMock = jest.spyOn(gh.rest.issues, 'addLabels');
|
const addLabelsMock = jest.spyOn(gh.rest.issues, "addLabels");
|
||||||
const removeLabelMock = jest.spyOn(gh.rest.issues, 'removeLabel');
|
const removeLabelMock = jest.spyOn(gh.rest.issues, "removeLabel");
|
||||||
const reposMock = jest.spyOn(gh.rest.repos, 'getContent');
|
const reposMock = jest.spyOn(gh.rest.repos, "getContent");
|
||||||
const paginateMock = jest.spyOn(gh, 'paginate');
|
const paginateMock = jest.spyOn(gh, "paginate");
|
||||||
const getPullMock = jest.spyOn(gh.rest.pulls, 'get');
|
const getPullMock = jest.spyOn(gh.rest.pulls, "get");
|
||||||
|
|
||||||
const yamlFixtures = {
|
const yamlFixtures = {
|
||||||
'branches.yml': fs.readFileSync('__tests__/fixtures/branches.yml'),
|
"only_pdfs.yml": fs.readFileSync("__tests__/fixtures/only_pdfs.yml"),
|
||||||
'only_pdfs.yml': fs.readFileSync('__tests__/fixtures/only_pdfs.yml'),
|
|
||||||
'not_supported.yml': fs.readFileSync('__tests__/fixtures/not_supported.yml'),
|
|
||||||
'any_and_all.yml': fs.readFileSync('__tests__/fixtures/any_and_all.yml')
|
|
||||||
};
|
};
|
||||||
|
|
||||||
afterAll(() => jest.restoreAllMocks());
|
afterAll(() => jest.restoreAllMocks());
|
||||||
|
|
||||||
describe('run', () => {
|
describe("run", () => {
|
||||||
it('adds labels to PRs that match our glob patterns', async () => {
|
it("adds labels to PRs that match our glob patterns", async () => {
|
||||||
usingLabelerConfigYaml('only_pdfs.yml');
|
usingLabelerConfigYaml("only_pdfs.yml");
|
||||||
mockGitHubResponseChangedFiles('foo.pdf');
|
mockGitHubResponseChangedFiles("foo.pdf");
|
||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(removeLabelMock).toHaveBeenCalledTimes(0);
|
expect(removeLabelMock).toHaveBeenCalledTimes(0);
|
||||||
expect(addLabelsMock).toHaveBeenCalledTimes(1);
|
expect(addLabelsMock).toHaveBeenCalledTimes(1);
|
||||||
expect(addLabelsMock).toHaveBeenCalledWith({
|
expect(addLabelsMock).toHaveBeenCalledWith({
|
||||||
owner: 'monalisa',
|
owner: "monalisa",
|
||||||
repo: 'helloworld',
|
repo: "helloworld",
|
||||||
issue_number: 123,
|
issue_number: 123,
|
||||||
labels: ['touched-a-pdf-file']
|
labels: ["touched-a-pdf-file"],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not add labels to PRs that do not match our glob patterns', async () => {
|
it("does not add labels to PRs that do not match our glob patterns", async () => {
|
||||||
usingLabelerConfigYaml('only_pdfs.yml');
|
usingLabelerConfigYaml("only_pdfs.yml");
|
||||||
mockGitHubResponseChangedFiles('foo.txt');
|
mockGitHubResponseChangedFiles("foo.txt");
|
||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
@@ -50,36 +47,23 @@ describe('run', () => {
|
|||||||
expect(addLabelsMock).toHaveBeenCalledTimes(0);
|
expect(addLabelsMock).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not add a label when the match config options are not supported', async () => {
|
it("(with sync-labels: true) it deletes preexisting PR labels that no longer match the glob pattern", async () => {
|
||||||
usingLabelerConfigYaml('not_supported.yml');
|
let mockInput = {
|
||||||
await run();
|
"repo-token": "foo",
|
||||||
|
"configuration-path": "bar",
|
||||||
expect(addLabelsMock).toHaveBeenCalledTimes(0);
|
"sync-labels": true,
|
||||||
expect(removeLabelMock).toHaveBeenCalledTimes(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('(with sync-labels: true) it deletes preexisting PR labels that no longer match the glob pattern', async () => {
|
|
||||||
const mockInput = {
|
|
||||||
'repo-token': 'foo',
|
|
||||||
'configuration-path': 'bar',
|
|
||||||
'sync-labels': 'true'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.spyOn(core, 'getInput')
|
.spyOn(core, "getInput")
|
||||||
.mockImplementation((name: string, ...opts) => mockInput[name]);
|
.mockImplementation((name: string, ...opts) => mockInput[name]);
|
||||||
jest
|
|
||||||
.spyOn(core, 'getBooleanInput')
|
|
||||||
.mockImplementation(
|
|
||||||
(name: string, ...opts) => mockInput[name] === 'true'
|
|
||||||
);
|
|
||||||
|
|
||||||
usingLabelerConfigYaml('only_pdfs.yml');
|
usingLabelerConfigYaml("only_pdfs.yml");
|
||||||
mockGitHubResponseChangedFiles('foo.txt');
|
mockGitHubResponseChangedFiles("foo.txt");
|
||||||
getPullMock.mockResolvedValue(<any>{
|
getPullMock.mockResolvedValue(<any>{
|
||||||
data: {
|
data: {
|
||||||
labels: [{name: 'touched-a-pdf-file'}]
|
labels: [{ name: "touched-a-pdf-file" }],
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
await run();
|
await run();
|
||||||
@@ -87,35 +71,30 @@ describe('run', () => {
|
|||||||
expect(addLabelsMock).toHaveBeenCalledTimes(0);
|
expect(addLabelsMock).toHaveBeenCalledTimes(0);
|
||||||
expect(removeLabelMock).toHaveBeenCalledTimes(1);
|
expect(removeLabelMock).toHaveBeenCalledTimes(1);
|
||||||
expect(removeLabelMock).toHaveBeenCalledWith({
|
expect(removeLabelMock).toHaveBeenCalledWith({
|
||||||
owner: 'monalisa',
|
owner: "monalisa",
|
||||||
repo: 'helloworld',
|
repo: "helloworld",
|
||||||
issue_number: 123,
|
issue_number: 123,
|
||||||
name: 'touched-a-pdf-file'
|
name: "touched-a-pdf-file",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('(with sync-labels: false) it issues no delete calls even when there are preexisting PR labels that no longer match the glob pattern', async () => {
|
it("(with sync-labels: false) it issues no delete calls even when there are preexisting PR labels that no longer match the glob pattern", async () => {
|
||||||
const mockInput = {
|
let mockInput = {
|
||||||
'repo-token': 'foo',
|
"repo-token": "foo",
|
||||||
'configuration-path': 'bar',
|
"configuration-path": "bar",
|
||||||
'sync-labels': 'false'
|
"sync-labels": false,
|
||||||
};
|
};
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.spyOn(core, 'getInput')
|
.spyOn(core, "getInput")
|
||||||
.mockImplementation((name: string, ...opts) => mockInput[name]);
|
.mockImplementation((name: string, ...opts) => mockInput[name]);
|
||||||
jest
|
|
||||||
.spyOn(core, 'getBooleanInput')
|
|
||||||
.mockImplementation(
|
|
||||||
(name: string, ...opts) => mockInput[name] === 'true'
|
|
||||||
);
|
|
||||||
|
|
||||||
usingLabelerConfigYaml('only_pdfs.yml');
|
usingLabelerConfigYaml("only_pdfs.yml");
|
||||||
mockGitHubResponseChangedFiles('foo.txt');
|
mockGitHubResponseChangedFiles("foo.txt");
|
||||||
getPullMock.mockResolvedValue(<any>{
|
getPullMock.mockResolvedValue(<any>{
|
||||||
data: {
|
data: {
|
||||||
labels: [{name: 'touched-a-pdf-file'}]
|
labels: [{ name: "touched-a-pdf-file" }],
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
await run();
|
await run();
|
||||||
@@ -123,96 +102,15 @@ describe('run', () => {
|
|||||||
expect(addLabelsMock).toHaveBeenCalledTimes(0);
|
expect(addLabelsMock).toHaveBeenCalledTimes(0);
|
||||||
expect(removeLabelMock).toHaveBeenCalledTimes(0);
|
expect(removeLabelMock).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds labels based on the branch names that match the regexp pattern', async () => {
|
|
||||||
github.context.payload.pull_request!.head = {ref: 'test/testing-time'};
|
|
||||||
usingLabelerConfigYaml('branches.yml');
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(addLabelsMock).toHaveBeenCalledTimes(1);
|
|
||||||
expect(addLabelsMock).toHaveBeenCalledWith({
|
|
||||||
owner: 'monalisa',
|
|
||||||
repo: 'helloworld',
|
|
||||||
issue_number: 123,
|
|
||||||
labels: ['test-branch']
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('adds multiple labels based on branch names that match different regexp patterns', async () => {
|
|
||||||
github.context.payload.pull_request!.head = {
|
|
||||||
ref: 'test/feature/123'
|
|
||||||
};
|
|
||||||
usingLabelerConfigYaml('branches.yml');
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(addLabelsMock).toHaveBeenCalledTimes(1);
|
|
||||||
expect(addLabelsMock).toHaveBeenCalledWith({
|
|
||||||
owner: 'monalisa',
|
|
||||||
repo: 'helloworld',
|
|
||||||
issue_number: 123,
|
|
||||||
labels: ['test-branch', 'feature-branch']
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can support multiple branches by batching', async () => {
|
|
||||||
github.context.payload.pull_request!.head = {ref: 'fix/123'};
|
|
||||||
usingLabelerConfigYaml('branches.yml');
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(addLabelsMock).toHaveBeenCalledTimes(1);
|
|
||||||
expect(addLabelsMock).toHaveBeenCalledWith({
|
|
||||||
owner: 'monalisa',
|
|
||||||
repo: 'helloworld',
|
|
||||||
issue_number: 123,
|
|
||||||
labels: ['bug-branch']
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can support multiple branches by providing an array', async () => {
|
|
||||||
github.context.payload.pull_request!.head = {ref: 'array/123'};
|
|
||||||
usingLabelerConfigYaml('branches.yml');
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(addLabelsMock).toHaveBeenCalledTimes(1);
|
|
||||||
expect(addLabelsMock).toHaveBeenCalledWith({
|
|
||||||
owner: 'monalisa',
|
|
||||||
repo: 'helloworld',
|
|
||||||
issue_number: 123,
|
|
||||||
labels: ['array-branch']
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('adds a label when matching any and all patterns are provided', async () => {
|
|
||||||
usingLabelerConfigYaml('any_and_all.yml');
|
|
||||||
mockGitHubResponseChangedFiles('tests/test.ts');
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(addLabelsMock).toHaveBeenCalledTimes(1);
|
|
||||||
expect(addLabelsMock).toHaveBeenCalledWith({
|
|
||||||
owner: 'monalisa',
|
|
||||||
repo: 'helloworld',
|
|
||||||
issue_number: 123,
|
|
||||||
labels: ['tests']
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not add a label when not all any and all patterns are matched', async () => {
|
|
||||||
usingLabelerConfigYaml('any_and_all.yml');
|
|
||||||
mockGitHubResponseChangedFiles('tests/requirements.txt');
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(addLabelsMock).toHaveBeenCalledTimes(0);
|
|
||||||
expect(removeLabelMock).toHaveBeenCalledTimes(0);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function usingLabelerConfigYaml(fixtureName: keyof typeof yamlFixtures): void {
|
function usingLabelerConfigYaml(fixtureName: keyof typeof yamlFixtures): void {
|
||||||
reposMock.mockResolvedValue(<any>{
|
reposMock.mockResolvedValue(<any>{
|
||||||
data: {content: yamlFixtures[fixtureName], encoding: 'utf8'}
|
data: { content: yamlFixtures[fixtureName], encoding: "utf8" },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function mockGitHubResponseChangedFiles(...files: string[]): void {
|
function mockGitHubResponseChangedFiles(...files: string[]): void {
|
||||||
const returnValue = files.map(f => ({filename: f}));
|
const returnValue = files.map((f) => ({ filename: f }));
|
||||||
paginateMock.mockReturnValue(<any>returnValue);
|
paginateMock.mockReturnValue(<any>returnValue);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ description: 'Automatically label new pull requests based on the paths of files
|
|||||||
author: 'GitHub'
|
author: 'GitHub'
|
||||||
inputs:
|
inputs:
|
||||||
repo-token:
|
repo-token:
|
||||||
description: 'The GitHub token used to manage labels'
|
description: 'The GITHUB_TOKEN secret'
|
||||||
required: false
|
|
||||||
default: ${{ github.token }}
|
|
||||||
configuration-path:
|
configuration-path:
|
||||||
description: 'The path for the label configurations'
|
description: 'The path for the label configurations'
|
||||||
default: '.github/labeler.yml'
|
default: '.github/labeler.yml'
|
||||||
@@ -16,5 +14,5 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node12'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|||||||
8237
dist/index.js
vendored
8237
dist/index.js
vendored
File diff suppressed because one or more lines are too long
22437
package-lock.json
generated
22437
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
37
package.json
37
package.json
@@ -1,14 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "labeler",
|
"name": "labeler",
|
||||||
"version": "4.0.1",
|
"version": "3.0.2",
|
||||||
"description": "Labels pull requests by files altered",
|
"description": "Labels pull requests by files altered",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc && ncc build lib/main.js",
|
"build": "tsc && ncc build lib/main.js",
|
||||||
"format": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --write \"**/*.{ts,yml,yaml}\"",
|
"format": "prettier --write \"**/*.ts\"",
|
||||||
"format-check": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --check \"**/*.{ts,yml,yaml}\"",
|
"format-check": "prettier --check \"**/*.ts\"",
|
||||||
"lint": "eslint --config ./.eslintrc.js \"**/*.ts\"",
|
|
||||||
"lint:fix": "eslint --config ./.eslintrc.js \"**/*.ts\" --fix",
|
|
||||||
"test": "jest"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -24,25 +22,20 @@
|
|||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.4.0",
|
||||||
"@actions/github": "^5.1.1",
|
"@actions/github": "^5.0.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"minimatch": "^7.4.3"
|
"minimatch": "^3.0.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^27.4.1",
|
"@types/jest": "^26.0.23",
|
||||||
"@types/js-yaml": "^4.0.5",
|
"@types/node": "^15.12.2",
|
||||||
"@types/minimatch": "^5.1.2",
|
"@types/minimatch": "^3.0.4",
|
||||||
"@types/node": "^16.11.7",
|
"@types/js-yaml": "^4.0.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.59.7",
|
"@vercel/ncc": "^0.28.6",
|
||||||
"@typescript-eslint/parser": "^5.59.7",
|
"jest": "^27.0.4",
|
||||||
"@vercel/ncc": "^0.36.1",
|
"prettier": "^2.3.1",
|
||||||
"eslint": "^8.41.0",
|
"ts-jest": "^27.0.3",
|
||||||
"eslint-config-prettier": "^8.8.0",
|
"typescript": "^4.3.4"
|
||||||
"eslint-plugin-jest": "^27.2.1",
|
|
||||||
"jest": "^27.5.1",
|
|
||||||
"prettier": "^2.8.8",
|
|
||||||
"ts-jest": "^27.1.3",
|
|
||||||
"typescript": "^4.9.5"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,98 +0,0 @@
|
|||||||
import * as core from '@actions/core';
|
|
||||||
import * as github from '@actions/github';
|
|
||||||
|
|
||||||
export interface BranchMatchConfig {
|
|
||||||
headBranch?: string[];
|
|
||||||
baseBranch?: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
type BranchBase = 'base' | 'head';
|
|
||||||
|
|
||||||
export function toBranchMatchConfig(config: any): BranchMatchConfig {
|
|
||||||
if (!config['head-branch'] && !config['base-branch']) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
const branchConfig = {
|
|
||||||
headBranch: config['head-branch'],
|
|
||||||
baseBranch: config['base-branch']
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const branchName in branchConfig) {
|
|
||||||
if (typeof branchConfig[branchName] === 'string') {
|
|
||||||
branchConfig[branchName] = [branchConfig[branchName]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return branchConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getBranchName(branchBase: BranchBase): string | undefined {
|
|
||||||
const pullRequest = github.context.payload.pull_request;
|
|
||||||
if (!pullRequest) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (branchBase === 'base') {
|
|
||||||
return pullRequest.base?.ref;
|
|
||||||
} else {
|
|
||||||
return pullRequest.head?.ref;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function checkAnyBranch(
|
|
||||||
regexps: string[],
|
|
||||||
branchBase: BranchBase
|
|
||||||
): boolean {
|
|
||||||
const branchName = getBranchName(branchBase);
|
|
||||||
if (!branchName) {
|
|
||||||
core.debug(` no branch name`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
core.debug(` checking "branch" pattern against ${branchName}`);
|
|
||||||
const matchers = regexps.map(regexp => new RegExp(regexp));
|
|
||||||
for (const matcher of matchers) {
|
|
||||||
if (matchBranchPattern(matcher, branchName)) {
|
|
||||||
core.debug(` "branch" patterns matched against ${branchName}`);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
core.debug(` "branch" patterns did not match against ${branchName}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function checkAllBranch(
|
|
||||||
regexps: string[],
|
|
||||||
branchBase: BranchBase
|
|
||||||
): boolean {
|
|
||||||
const branchName = getBranchName(branchBase);
|
|
||||||
if (!branchName) {
|
|
||||||
core.debug(` cannot fetch branch name from the pull request`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
core.debug(` checking "branch" pattern against ${branchName}`);
|
|
||||||
const matchers = regexps.map(regexp => new RegExp(regexp));
|
|
||||||
for (const matcher of matchers) {
|
|
||||||
if (!matchBranchPattern(matcher, branchName)) {
|
|
||||||
core.debug(` "branch" patterns did not match against ${branchName}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
core.debug(` "branch" patterns matched against ${branchName}`);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function matchBranchPattern(matcher: RegExp, branchName: string): boolean {
|
|
||||||
core.debug(` - ${matcher}`);
|
|
||||||
if (matcher.test(branchName)) {
|
|
||||||
core.debug(` "branch" pattern matched`);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
core.debug(` ${matcher} did not match`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
import * as core from '@actions/core';
|
|
||||||
import * as github from '@actions/github';
|
|
||||||
import {Minimatch} from 'minimatch';
|
|
||||||
|
|
||||||
export interface ChangedFilesMatchConfig {
|
|
||||||
changedFiles?: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
type ClientType = ReturnType<typeof github.getOctokit>;
|
|
||||||
|
|
||||||
export async function getChangedFiles(
|
|
||||||
client: ClientType,
|
|
||||||
prNumber: number
|
|
||||||
): Promise<string[]> {
|
|
||||||
const listFilesOptions = client.rest.pulls.listFiles.endpoint.merge({
|
|
||||||
owner: github.context.repo.owner,
|
|
||||||
repo: github.context.repo.repo,
|
|
||||||
pull_number: prNumber
|
|
||||||
});
|
|
||||||
|
|
||||||
const listFilesResponse = await client.paginate(listFilesOptions);
|
|
||||||
const changedFiles = listFilesResponse.map((f: any) => f.filename);
|
|
||||||
|
|
||||||
core.debug('found changed files:');
|
|
||||||
for (const file of changedFiles) {
|
|
||||||
core.debug(' ' + file);
|
|
||||||
}
|
|
||||||
|
|
||||||
return changedFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function toChangedFilesMatchConfig(
|
|
||||||
config: any
|
|
||||||
): ChangedFilesMatchConfig {
|
|
||||||
if (!config['changed-files'] || !config['changed-files'].length) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
const changedFilesConfig = config['changed-files'];
|
|
||||||
|
|
||||||
return {
|
|
||||||
changedFiles: Array.isArray(changedFilesConfig)
|
|
||||||
? changedFilesConfig
|
|
||||||
: [changedFilesConfig]
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function printPattern(matcher: Minimatch): string {
|
|
||||||
return (matcher.negate ? '!' : '') + matcher.pattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isAnyMatch(changedFile: string, matchers: Minimatch[]): boolean {
|
|
||||||
core.debug(` matching patterns against file ${changedFile}`);
|
|
||||||
for (const matcher of matchers) {
|
|
||||||
core.debug(` - ${printPattern(matcher)}`);
|
|
||||||
if (matcher.match(changedFile)) {
|
|
||||||
core.debug(` ${printPattern(matcher)} matched`);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
core.debug(` no patterns matched`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isAllMatch(changedFile: string, matchers: Minimatch[]): boolean {
|
|
||||||
core.debug(` matching patterns against file ${changedFile}`);
|
|
||||||
for (const matcher of matchers) {
|
|
||||||
core.debug(` - ${printPattern(matcher)}`);
|
|
||||||
if (!matcher.match(changedFile)) {
|
|
||||||
core.debug(` ${printPattern(matcher)} did not match`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
core.debug(` all patterns matched`);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function checkAnyChangedFiles(
|
|
||||||
changedFiles: string[],
|
|
||||||
globs: string[]
|
|
||||||
): boolean {
|
|
||||||
const matchers = globs.map(g => new Minimatch(g));
|
|
||||||
for (const changedFile of changedFiles) {
|
|
||||||
if (isAnyMatch(changedFile, matchers)) {
|
|
||||||
core.debug(` "any" patterns matched against ${changedFile}`);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
core.debug(` "any" patterns did not match any files`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function checkAllChangedFiles(
|
|
||||||
changedFiles: string[],
|
|
||||||
globs: string[]
|
|
||||||
): boolean {
|
|
||||||
const matchers = globs.map(g => new Minimatch(g));
|
|
||||||
for (const changedFile of changedFiles) {
|
|
||||||
if (!isAllMatch(changedFile, matchers)) {
|
|
||||||
core.debug(` "all" patterns did not match against ${changedFile}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
core.debug(` "all" patterns matched all files`);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
305
src/labeler.ts
305
src/labeler.ts
@@ -1,66 +1,50 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from "@actions/core";
|
||||||
import * as github from '@actions/github';
|
import * as github from "@actions/github";
|
||||||
import * as yaml from 'js-yaml';
|
import * as yaml from "js-yaml";
|
||||||
|
import { Minimatch, IMinimatch } from "minimatch";
|
||||||
|
|
||||||
import {
|
interface MatchConfig {
|
||||||
ChangedFilesMatchConfig,
|
all?: string[];
|
||||||
getChangedFiles,
|
any?: string[];
|
||||||
toChangedFilesMatchConfig,
|
}
|
||||||
checkAllChangedFiles,
|
|
||||||
checkAnyChangedFiles
|
|
||||||
} from './changedFiles';
|
|
||||||
import {
|
|
||||||
checkAnyBranch,
|
|
||||||
checkAllBranch,
|
|
||||||
toBranchMatchConfig,
|
|
||||||
BranchMatchConfig
|
|
||||||
} from './branch';
|
|
||||||
|
|
||||||
export type BaseMatchConfig = BranchMatchConfig & ChangedFilesMatchConfig;
|
|
||||||
|
|
||||||
export type MatchConfig = {
|
|
||||||
any?: BaseMatchConfig[];
|
|
||||||
all?: BaseMatchConfig[];
|
|
||||||
};
|
|
||||||
|
|
||||||
|
type StringOrMatchConfig = string | MatchConfig;
|
||||||
type ClientType = ReturnType<typeof github.getOctokit>;
|
type ClientType = ReturnType<typeof github.getOctokit>;
|
||||||
|
|
||||||
const ALLOWED_CONFIG_KEYS = ['changed-files', 'head-branch', 'base-branch'];
|
|
||||||
|
|
||||||
export async function run() {
|
export async function run() {
|
||||||
try {
|
try {
|
||||||
const token = core.getInput('repo-token');
|
const token = core.getInput("repo-token", { required: true });
|
||||||
const configPath = core.getInput('configuration-path', {required: true});
|
const configPath = core.getInput("configuration-path", { required: true });
|
||||||
const syncLabels = core.getBooleanInput('sync-labels');
|
const syncLabels = !!core.getInput("sync-labels", { required: false });
|
||||||
|
|
||||||
const prNumber = getPrNumber();
|
const prNumber = getPrNumber();
|
||||||
if (!prNumber) {
|
if (!prNumber) {
|
||||||
core.info('Could not get pull request number from context, exiting');
|
console.log("Could not get pull request number from context, exiting");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const client: ClientType = github.getOctokit(token);
|
const client: ClientType = github.getOctokit(token);
|
||||||
|
|
||||||
const {data: pullRequest} = await client.rest.pulls.get({
|
const { data: pullRequest } = await client.rest.pulls.get({
|
||||||
owner: github.context.repo.owner,
|
owner: github.context.repo.owner,
|
||||||
repo: github.context.repo.repo,
|
repo: github.context.repo.repo,
|
||||||
pull_number: prNumber
|
pull_number: prNumber,
|
||||||
});
|
});
|
||||||
|
|
||||||
core.debug(`fetching changed files for pr #${prNumber}`);
|
core.debug(`fetching changed files for pr #${prNumber}`);
|
||||||
const changedFiles: string[] = await getChangedFiles(client, prNumber);
|
const changedFiles: string[] = await getChangedFiles(client, prNumber);
|
||||||
const labelConfigs: Map<string, MatchConfig[]> = await getMatchConfigs(
|
const labelGlobs: Map<string, StringOrMatchConfig[]> = await getLabelGlobs(
|
||||||
client,
|
client,
|
||||||
configPath
|
configPath
|
||||||
);
|
);
|
||||||
|
|
||||||
const labels: string[] = [];
|
const labels: string[] = [];
|
||||||
const labelsToRemove: string[] = [];
|
const labelsToRemove: string[] = [];
|
||||||
for (const [label, configs] of labelConfigs.entries()) {
|
for (const [label, globs] of labelGlobs.entries()) {
|
||||||
core.debug(`processing ${label}`);
|
core.debug(`processing ${label}`);
|
||||||
if (checkMatchConfigs(changedFiles, configs)) {
|
if (checkGlobs(changedFiles, globs)) {
|
||||||
labels.push(label);
|
labels.push(label);
|
||||||
} else if (pullRequest.labels.find(l => l.name === label)) {
|
} else if (pullRequest.labels.find((l) => l.name === label)) {
|
||||||
labelsToRemove.push(label);
|
labelsToRemove.push(label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,7 +56,7 @@ export async function run() {
|
|||||||
if (syncLabels && labelsToRemove.length) {
|
if (syncLabels && labelsToRemove.length) {
|
||||||
await removeLabels(client, prNumber, labelsToRemove);
|
await removeLabels(client, prNumber, labelsToRemove);
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error) {
|
||||||
core.error(error);
|
core.error(error);
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
@@ -87,20 +71,41 @@ function getPrNumber(): number | undefined {
|
|||||||
return pullRequest.number;
|
return pullRequest.number;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getMatchConfigs(
|
async function getChangedFiles(
|
||||||
|
client: ClientType,
|
||||||
|
prNumber: number
|
||||||
|
): Promise<string[]> {
|
||||||
|
const listFilesOptions = client.rest.pulls.listFiles.endpoint.merge({
|
||||||
|
owner: github.context.repo.owner,
|
||||||
|
repo: github.context.repo.repo,
|
||||||
|
pull_number: prNumber,
|
||||||
|
});
|
||||||
|
|
||||||
|
const listFilesResponse = await client.paginate(listFilesOptions);
|
||||||
|
const changedFiles = listFilesResponse.map((f: any) => f.filename);
|
||||||
|
|
||||||
|
core.debug("found changed files:");
|
||||||
|
for (const file of changedFiles) {
|
||||||
|
core.debug(" " + file);
|
||||||
|
}
|
||||||
|
|
||||||
|
return changedFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getLabelGlobs(
|
||||||
client: ClientType,
|
client: ClientType,
|
||||||
configurationPath: string
|
configurationPath: string
|
||||||
): Promise<Map<string, MatchConfig[]>> {
|
): Promise<Map<string, StringOrMatchConfig[]>> {
|
||||||
const configurationContent: string = await fetchContent(
|
const configurationContent: string = await fetchContent(
|
||||||
client,
|
client,
|
||||||
configurationPath
|
configurationPath
|
||||||
);
|
);
|
||||||
|
|
||||||
// loads (hopefully) a `{[label:string]: MatchConfig[]}`, but is `any`:
|
// loads (hopefully) a `{[label:string]: string | StringOrMatchConfig[]}`, but is `any`:
|
||||||
const configObject: any = yaml.load(configurationContent);
|
const configObject: any = yaml.load(configurationContent);
|
||||||
|
|
||||||
// transform `any` => `Map<string,MatchConfig[]>` or throw if yaml is malformed:
|
// transform `any` => `Map<string,StringOrMatchConfig[]>` or throw if yaml is malformed:
|
||||||
return getLabelConfigMapFromObject(configObject);
|
return getLabelGlobMapFromObject(configObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchContent(
|
async function fetchContent(
|
||||||
@@ -111,192 +116,116 @@ async function fetchContent(
|
|||||||
owner: github.context.repo.owner,
|
owner: github.context.repo.owner,
|
||||||
repo: github.context.repo.repo,
|
repo: github.context.repo.repo,
|
||||||
path: repoPath,
|
path: repoPath,
|
||||||
ref: github.context.sha
|
ref: github.context.sha,
|
||||||
});
|
});
|
||||||
|
|
||||||
return Buffer.from(response.data.content, response.data.encoding).toString();
|
return Buffer.from(response.data.content, response.data.encoding).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLabelConfigMapFromObject(
|
function getLabelGlobMapFromObject(
|
||||||
configObject: any
|
configObject: any
|
||||||
): Map<string, MatchConfig[]> {
|
): Map<string, StringOrMatchConfig[]> {
|
||||||
const labelMap: Map<string, MatchConfig[]> = new Map();
|
const labelGlobs: Map<string, StringOrMatchConfig[]> = new Map();
|
||||||
for (const label in configObject) {
|
for (const label in configObject) {
|
||||||
const configOptions = configObject[label];
|
if (typeof configObject[label] === "string") {
|
||||||
if (
|
labelGlobs.set(label, [configObject[label]]);
|
||||||
!Array.isArray(configOptions) ||
|
} else if (configObject[label] instanceof Array) {
|
||||||
!configOptions.every(opts => typeof opts === 'object')
|
labelGlobs.set(label, configObject[label]);
|
||||||
) {
|
} else {
|
||||||
throw Error(
|
throw Error(
|
||||||
`found unexpected type for label '${label}' (should be array of config options)`
|
`found unexpected type for label ${label} (should be string or array of globs)`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const matchConfigs = configOptions.reduce<MatchConfig[]>(
|
|
||||||
(updatedConfig, configValue) => {
|
|
||||||
if (!configValue) {
|
|
||||||
return updatedConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
Object.entries(configValue).forEach(([key, value]) => {
|
|
||||||
// If the top level `any` or `all` keys are provided then set them, and convert their values to
|
|
||||||
// our config objects.
|
|
||||||
if (key === 'any' || key === 'all') {
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
const newConfigs = value.map(toMatchConfig);
|
|
||||||
updatedConfig.push({[key]: newConfigs});
|
|
||||||
}
|
|
||||||
} else if (ALLOWED_CONFIG_KEYS.includes(key)) {
|
|
||||||
const newMatchConfig = toMatchConfig({[key]: value});
|
|
||||||
// Find or set the `any` key so that we can add these properties to that rule,
|
|
||||||
// Or create a new `any` key and add that to our array of configs.
|
|
||||||
const indexOfAny = updatedConfig.findIndex(mc => !!mc['any']);
|
|
||||||
if (indexOfAny >= 0) {
|
|
||||||
updatedConfig[indexOfAny].any?.push(newMatchConfig);
|
|
||||||
} else {
|
|
||||||
updatedConfig.push({any: [newMatchConfig]});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Log the key that we don't know what to do with.
|
|
||||||
core.info(`An unknown config option was under ${label}: ${key}`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return updatedConfig;
|
|
||||||
},
|
|
||||||
[]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (matchConfigs.length) {
|
|
||||||
labelMap.set(label, matchConfigs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return labelMap;
|
return labelGlobs;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toMatchConfig(config: any): BaseMatchConfig {
|
function toMatchConfig(config: StringOrMatchConfig): MatchConfig {
|
||||||
const changedFilesConfig = toChangedFilesMatchConfig(config);
|
if (typeof config === "string") {
|
||||||
const branchConfig = toBranchMatchConfig(config);
|
return {
|
||||||
|
any: [config],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return config;
|
||||||
...changedFilesConfig,
|
|
||||||
...branchConfig
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function checkMatchConfigs(
|
function printPattern(matcher: IMinimatch): string {
|
||||||
|
return (matcher.negate ? "!" : "") + matcher.pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function checkGlobs(
|
||||||
changedFiles: string[],
|
changedFiles: string[],
|
||||||
matchConfigs: MatchConfig[]
|
globs: StringOrMatchConfig[]
|
||||||
): boolean {
|
): boolean {
|
||||||
for (const config of matchConfigs) {
|
for (const glob of globs) {
|
||||||
core.debug(` checking config ${JSON.stringify(config)}`);
|
core.debug(` checking pattern ${JSON.stringify(glob)}`);
|
||||||
if (!checkMatch(changedFiles, config)) {
|
const matchConfig = toMatchConfig(glob);
|
||||||
return false;
|
if (checkMatch(changedFiles, matchConfig)) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkMatch(changedFiles: string[], matchConfig: MatchConfig): boolean {
|
function isMatch(changedFile: string, matchers: IMinimatch[]): boolean {
|
||||||
if (!Object.keys(matchConfig).length) {
|
core.debug(` matching patterns against file ${changedFile}`);
|
||||||
core.debug(` no "any" or "all" patterns to check`);
|
for (const matcher of matchers) {
|
||||||
return false;
|
core.debug(` - ${printPattern(matcher)}`);
|
||||||
}
|
if (!matcher.match(changedFile)) {
|
||||||
|
core.debug(` ${printPattern(matcher)} did not match`);
|
||||||
if (matchConfig.all) {
|
|
||||||
if (!checkAll(matchConfig.all, changedFiles)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (matchConfig.any) {
|
|
||||||
if (!checkAny(matchConfig.any, changedFiles)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
core.debug(` all patterns matched`);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// equivalent to "Array.some()" but expanded for debugging and clarity
|
// equivalent to "Array.some()" but expanded for debugging and clarity
|
||||||
export function checkAny(
|
function checkAny(changedFiles: string[], globs: string[]): boolean {
|
||||||
matchConfigs: BaseMatchConfig[],
|
const matchers = globs.map((g) => new Minimatch(g));
|
||||||
changedFiles: string[]
|
|
||||||
): boolean {
|
|
||||||
core.debug(` checking "any" patterns`);
|
core.debug(` checking "any" patterns`);
|
||||||
if (
|
for (const changedFile of changedFiles) {
|
||||||
!matchConfigs.length ||
|
if (isMatch(changedFile, matchers)) {
|
||||||
!matchConfigs.some(configOption => Object.keys(configOption).length)
|
core.debug(` "any" patterns matched against ${changedFile}`);
|
||||||
) {
|
return true;
|
||||||
core.debug(` no "any" patterns to check`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const matchConfig of matchConfigs) {
|
|
||||||
if (matchConfig.baseBranch) {
|
|
||||||
if (checkAnyBranch(matchConfig.baseBranch, 'base')) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (matchConfig.changedFiles) {
|
|
||||||
if (checkAnyChangedFiles(changedFiles, matchConfig.changedFiles)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (matchConfig.headBranch) {
|
|
||||||
if (checkAnyBranch(matchConfig.headBranch, 'head')) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
core.debug(` "any" patterns did not match any configs`);
|
core.debug(` "any" patterns did not match any files`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// equivalent to "Array.every()" but expanded for debugging and clarity
|
// equivalent to "Array.every()" but expanded for debugging and clarity
|
||||||
export function checkAll(
|
function checkAll(changedFiles: string[], globs: string[]): boolean {
|
||||||
matchConfigs: BaseMatchConfig[],
|
const matchers = globs.map((g) => new Minimatch(g));
|
||||||
changedFiles: string[]
|
core.debug(` checking "all" patterns`);
|
||||||
): boolean {
|
for (const changedFile of changedFiles) {
|
||||||
core.debug(` checking "all" patterns`);
|
if (!isMatch(changedFile, matchers)) {
|
||||||
if (
|
core.debug(` "all" patterns did not match against ${changedFile}`);
|
||||||
!matchConfigs.length ||
|
return false;
|
||||||
!matchConfigs.some(configOption => Object.keys(configOption).length)
|
}
|
||||||
) {
|
}
|
||||||
core.debug(` no "all" patterns to check`);
|
|
||||||
return false;
|
core.debug(` "all" patterns matched all files`);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
for (const matchConfig of matchConfigs) {
|
|
||||||
if (matchConfig.baseBranch) {
|
function checkMatch(changedFiles: string[], matchConfig: MatchConfig): boolean {
|
||||||
if (!checkAllBranch(matchConfig.baseBranch, 'base')) {
|
if (matchConfig.all !== undefined) {
|
||||||
return false;
|
if (!checkAll(changedFiles, matchConfig.all)) {
|
||||||
}
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (matchConfig.changedFiles) {
|
|
||||||
if (!changedFiles.length) {
|
if (matchConfig.any !== undefined) {
|
||||||
core.debug(` no files to check "changed-files" patterns against`);
|
if (!checkAny(changedFiles, matchConfig.any)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (!checkAllChangedFiles(changedFiles, matchConfig.changedFiles)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (matchConfig.headBranch) {
|
|
||||||
if (!checkAllBranch(matchConfig.headBranch, 'head')) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
core.debug(` "all" patterns matched all configs`);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,7 +238,7 @@ async function addLabels(
|
|||||||
owner: github.context.repo.owner,
|
owner: github.context.repo.owner,
|
||||||
repo: github.context.repo.repo,
|
repo: github.context.repo.repo,
|
||||||
issue_number: prNumber,
|
issue_number: prNumber,
|
||||||
labels: labels
|
labels: labels,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,12 +248,12 @@ async function removeLabels(
|
|||||||
labels: string[]
|
labels: string[]
|
||||||
) {
|
) {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
labels.map(label =>
|
labels.map((label) =>
|
||||||
client.rest.issues.removeLabel({
|
client.rest.issues.removeLabel({
|
||||||
owner: github.context.repo.owner,
|
owner: github.context.repo.owner,
|
||||||
repo: github.context.repo.repo,
|
repo: github.context.repo.repo,
|
||||||
issue_number: prNumber,
|
issue_number: prNumber,
|
||||||
name: label
|
name: label,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
import {run} from './labeler';
|
import { run } from "./labeler";
|
||||||
|
|
||||||
run();
|
run();
|
||||||
|
|||||||
Reference in New Issue
Block a user