Skip to content

Commit

Permalink
Lock and close repo based on permission bierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
kntsoriano committed Nov 22, 2019
1 parent 45ace66 commit 12c1aa4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const core = require('@actions/core');
const github = require('@actions/github');
const permissionLevels = ["read", "triage", "write", "maintain", "admin"];

async function run() {
try {
Expand Down Expand Up @@ -34,8 +35,11 @@ async function run() {
username: github.context.actor
})
const permissionLevel = permission.data.permission
const permissionIndex = permissionLevels.indexOf(permissionLevel)
const closePermissionIndex = permissionLevels.indexOf(closePermission)
const lockPermissionIndex = permissionLevels.indexOf(lockPermission)

if (permissionLevel == closePermission) {
if (permissionIndex >= closePermissionIndex && permissionIndex <= lockPermissionIndex) {
core.debug(`Adding message: ${closeMessage} to Issue #${issue.number}`);

await client.issues.createComment({
Expand All @@ -53,7 +57,7 @@ async function run() {
issue_number: issue.number,
state: 'closed'
});
} else if (permissionLevel == lockPermission) {
} else if (permissionIndex >= lockPermissionIndex) {
core.debug(`Adding message: ${lockMessage} to Issue #${issue.number}`);

await client.issues.createComment({
Expand Down

0 comments on commit 12c1aa4

Please sign in to comment.