Skip to content

Commit

Permalink
remove label if no lfs warning
Browse files Browse the repository at this point in the history
  • Loading branch information
naseemkullah committed Aug 5, 2021
1 parent f8bb1f1 commit e3b08c4
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const context = github.context;
const {owner, repo} = context.repo;
const event_type = context.eventName;

const labels = ['lfs-detected!'];
const labelName = 'lfs-detected!'

// most @actions toolkit packages have async methods
async function run() {
Expand All @@ -24,7 +24,7 @@ async function run() {
await octokit.rest.issues.getLabel({
owner,
repo,
name: 'lfs-detected!',
name: labelName,
});
} catch (error) {
if (error.message === 'Not Found') {
Expand Down Expand Up @@ -132,7 +132,7 @@ async function run() {
owner,
repo,
issue_number: pullRequestNumber,
labels,
labels: [labelName],
});

await octokit.rest.issues.createComment({
Expand All @@ -148,6 +148,21 @@ async function run() {
);
} else {
core.info('No large file(s) detected...');

const {data: labels} = await octokit.rest.issues.listLabelsOnIssue({
owner,
repo,
issue_number: 1,
})
if (labels.map(l => l.name).includes(labelName)) {
await octokit.rest.issues.removeLabel({
owner,
repo,
issue_number: 1,
name: labelName
});
core.info(`label ${labelName} removed`)
}
}
} else {
core.info('No Pull Request detected. Skipping LFS warning check');
Expand Down

0 comments on commit e3b08c4

Please sign in to comment.