Skip to content

Commit

Permalink
Add label-fork property to handle forks
Browse files Browse the repository at this point in the history
Addresses actions#136
  • Loading branch information
jsoref committed Jun 13, 2023
1 parent 1ceb9e6 commit 5bab48d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ jobs:
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v4
- uses: actions/labeler@v5
with:
label-fork: "${{ secrets.LABEL_FORK }}"
```

#### Inputs
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ inputs:
description: 'Whether or not to auto-include paths starting with dot (e.g. `.github`)'
default: false
required: false
label-fork:
description: 'Label fork'
default: 'false'
required: false

runs:
using: 'node16'
Expand Down
6 changes: 6 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,18 @@ const github = __importStar(__nccwpck_require__(5438));
const yaml = __importStar(__nccwpck_require__(1917));
const minimatch_1 = __nccwpck_require__(2002);
function run() {
var _a;
return __awaiter(this, void 0, void 0, function* () {
try {
const token = core.getInput('repo-token');
const configPath = core.getInput('configuration-path', { required: true });
const syncLabels = !!core.getInput('sync-labels');
const dot = core.getBooleanInput('dot');
const labelFork = !!core.getInput('label-fork');
if (!labelFork && ((_a = github.context.payload.repository) === null || _a === void 0 ? void 0 : _a.fork)) {
console.log("Workflow is not configured to label forks, exiting");
return;
}
const prNumber = getPrNumber();
if (!prNumber) {
core.info('Could not get pull request number from context, exiting');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "labeler",
"version": "4.1.0",
"version": "5.0.0",
"description": "Labels pull requests by files altered",
"main": "lib/main.js",
"scripts": {
Expand Down
6 changes: 6 additions & 0 deletions src/labeler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ export async function run() {
const configPath = core.getInput('configuration-path', {required: true});
const syncLabels = !!core.getInput('sync-labels');
const dot = core.getBooleanInput('dot');
const labelFork = !!core.getInput('label-fork');

if (!labelFork && github.context.payload.repository?.fork) {
console.log("Workflow is not configured to label forks, exiting");
return;
}

const prNumber = getPrNumber();
if (!prNumber) {
Expand Down

0 comments on commit 5bab48d

Please sign in to comment.