Skip to content

Commit

Permalink
Add label-fork property to handle forks
Browse files Browse the repository at this point in the history
Addresses #136
  • Loading branch information
jsoref committed Jul 25, 2022
1 parent fc5e0f0 commit 29b7962
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ jobs:
- uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
label-fork: "${{ secrets.LABEL_FORK }}"
```

_Note: This grants access to the `GITHUB_TOKEN` so the action can make calls to GitHub's rest API_
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ inputs:
description: 'Whether or not to remove labels when matching files are reverted'
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 @@ -48,11 +48,17 @@ function stringToBoolean(input) {
return input.toLowerCase() === 'true' || input === '1';
}
function run() {
var _a;
return __awaiter(this, void 0, void 0, function* () {
try {
const token = core.getInput("repo-token", { required: true });
const configPath = core.getInput("configuration-path", { required: true });
const syncLabels = stringToBoolean(core.getInput("sync-labels", { required: false }));
const labelFork = stringToBoolean(core.getInput("label-fork", { required: false }));
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) {
console.log("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": "3.1.2",
"version": "4.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 @@ -20,6 +20,12 @@ export async function run() {
const token = core.getInput("repo-token", { required: true });
const configPath = core.getInput("configuration-path", { required: true });
const syncLabels = stringToBoolean(core.getInput("sync-labels", { required: false }));
const labelFork = stringToBoolean(core.getInput("label-fork", { required: false }));

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 29b7962

Please sign in to comment.