From 6edef94ff89a5be04b293f440027ed5333cb1577 Mon Sep 17 00:00:00 2001 From: Nara Kasbergen Kwon <855115+xiehan@users.noreply.github.com> Date: Wed, 18 Oct 2023 11:33:16 +0200 Subject: [PATCH 1/2] chore: improve identity checks in autoclose workflow --- src/auto-close-community-issues.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/auto-close-community-issues.ts b/src/auto-close-community-issues.ts index e061a96e..c9fc3de9 100644 --- a/src/auto-close-community-issues.ts +++ b/src/auto-close-community-issues.ts @@ -37,6 +37,7 @@ export class AutoCloseCommunityIssues { }, }); + const maintainerStatuses = `fromJSON('["OWNER", "MEMBER", "COLLABORATOR", "CONTRIBUTOR"]')`; const comment = `Hi there! 👋 We appreciate your interest, but this is probably not the right place. All the code in this repository is auto-generated using @@ -53,7 +54,7 @@ export class AutoCloseCommunityIssues { permissions: { issues: JobPermission.WRITE, }, - if: "github.event.issue.author_association != 'OWNER' && github.event.issue.author_association != 'MEMBER' && github.event.issue.author_association != 'COLLABORATOR'", + if: `github.event.issue.user.login == 'team-tf-cdk' || contains(${maintainerStatuses}, github.event.issue.author_association)`, steps: [ { name: "Checkout", @@ -84,7 +85,7 @@ export class AutoCloseCommunityIssues { permissions: { pullRequests: JobPermission.WRITE, }, - if: "github.event.pull_request.author_association != 'OWNER' && github.event.pull_request.author_association != 'MEMBER' && github.event.pull_request.author_association != 'COLLABORATOR'", + if: `github.event.pull_request.user.login == 'team-tf-cdk' || contains(${maintainerStatuses}, github.event.pull_request.author_association)`, steps: [ { name: "Checkout", From fa06ced0a98155ca0bc0ff1f2b43bf34bb656461 Mon Sep 17 00:00:00 2001 From: team-tf-cdk Date: Wed, 18 Oct 2023 09:44:00 +0000 Subject: [PATCH 2/2] chore: self mutation Signed-off-by: team-tf-cdk --- test/__snapshots__/index.test.ts.snap | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/__snapshots__/index.test.ts.snap b/test/__snapshots__/index.test.ts.snap index 83cfbdca..0d64b4e5 100644 --- a/test/__snapshots__/index.test.ts.snap +++ b/test/__snapshots__/index.test.ts.snap @@ -120,7 +120,7 @@ jobs: runs-on: ubuntu-latest permissions: issues: write - if: github.event.issue.author_association != 'OWNER' && github.event.issue.author_association != 'MEMBER' && github.event.issue.author_association != 'COLLABORATOR' + if: github.event.issue.user.login == 'team-tf-cdk' || contains(fromJSON('[\\"OWNER\\", \\"MEMBER\\", \\"COLLABORATOR\\", \\"CONTRIBUTOR\\"]'), github.event.issue.author_association) steps: - name: Checkout uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab @@ -145,7 +145,7 @@ jobs: runs-on: ubuntu-latest permissions: pull-requests: write - if: github.event.pull_request.author_association != 'OWNER' && github.event.pull_request.author_association != 'MEMBER' && github.event.pull_request.author_association != 'COLLABORATOR' + if: github.event.pull_request.user.login == 'team-tf-cdk' || contains(fromJSON('[\\"OWNER\\", \\"MEMBER\\", \\"COLLABORATOR\\", \\"CONTRIBUTOR\\"]'), github.event.pull_request.author_association) steps: - name: Checkout uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab @@ -2800,7 +2800,7 @@ jobs: runs-on: ubuntu-latest permissions: issues: write - if: github.event.issue.author_association != 'OWNER' && github.event.issue.author_association != 'MEMBER' && github.event.issue.author_association != 'COLLABORATOR' + if: github.event.issue.user.login == 'team-tf-cdk' || contains(fromJSON('[\\"OWNER\\", \\"MEMBER\\", \\"COLLABORATOR\\", \\"CONTRIBUTOR\\"]'), github.event.issue.author_association) steps: - name: Checkout uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab @@ -2825,7 +2825,7 @@ jobs: runs-on: ubuntu-latest permissions: pull-requests: write - if: github.event.pull_request.author_association != 'OWNER' && github.event.pull_request.author_association != 'MEMBER' && github.event.pull_request.author_association != 'COLLABORATOR' + if: github.event.pull_request.user.login == 'team-tf-cdk' || contains(fromJSON('[\\"OWNER\\", \\"MEMBER\\", \\"COLLABORATOR\\", \\"CONTRIBUTOR\\"]'), github.event.pull_request.author_association) steps: - name: Checkout uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab @@ -5531,7 +5531,7 @@ jobs: runs-on: ubuntu-latest permissions: issues: write - if: github.event.issue.author_association != 'OWNER' && github.event.issue.author_association != 'MEMBER' && github.event.issue.author_association != 'COLLABORATOR' + if: github.event.issue.user.login == 'team-tf-cdk' || contains(fromJSON('[\\"OWNER\\", \\"MEMBER\\", \\"COLLABORATOR\\", \\"CONTRIBUTOR\\"]'), github.event.issue.author_association) steps: - name: Checkout uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab @@ -5556,7 +5556,7 @@ jobs: runs-on: ubuntu-latest permissions: pull-requests: write - if: github.event.pull_request.author_association != 'OWNER' && github.event.pull_request.author_association != 'MEMBER' && github.event.pull_request.author_association != 'COLLABORATOR' + if: github.event.pull_request.user.login == 'team-tf-cdk' || contains(fromJSON('[\\"OWNER\\", \\"MEMBER\\", \\"COLLABORATOR\\", \\"CONTRIBUTOR\\"]'), github.event.pull_request.author_association) steps: - name: Checkout uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab