openai/openai-dotnet

Public

mirrored from https://github.com/openai/openai-dotnetAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/customize-openairesponsescontext-attribute

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.github/workflows/needs-triage.yml

64lines · modecode

1---
2name: Add needs-triage label
3
4'on':
5 issues:
6 types: [opened]
7
8jobs:
9 add-needs-triage:
10 runs-on: ubuntu-latest
11 permissions:
12 issues: write
13 repository-projects: read
14 steps:
15 - name: Check if issue already has labels
16 id: check-labels
17 uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
18 with:
19 script: |
20 const issue = context.payload.issue;
21 const hasLabels = issue.labels && issue.labels.length > 0;
22 core.setOutput('has-labels', hasLabels);
23 return hasLabels;
24
25 - name: Check if author has write permissions
26 id: check-permissions
27 if: steps.check-labels.outputs.has-labels == 'false'
28 uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
29 with:
30 script: |
31 const issue = context.payload.issue;
32 const author = issue.user.login;
33
34 try {
35 const { data: permission } = await github.rest.repos
36 .getCollaboratorPermissionLevel({
37 owner: context.repo.owner,
38 repo: context.repo.repo,
39 username: author
40 });
41
42 const hasWriteAccess = ['write', 'admin', 'maintain']
43 .includes(permission.permission);
44 core.setOutput('has-write-access', hasWriteAccess);
45 return hasWriteAccess;
46 } catch (error) {
47 // If user is not a collaborator, they don't have write access
48 core.setOutput('has-write-access', false);
49 return false;
50 }
51
52 - name: Add needs-triage label
53 if: >-
54 steps.check-labels.outputs.has-labels == 'false' &&
55 steps.check-permissions.outputs.has-write-access == 'false'
56 uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
57 with:
58 script: |
59 await github.rest.issues.addLabels({
60 owner: context.repo.owner,
61 repo: context.repo.repo,
62 issue_number: context.payload.issue.number,
63 labels: ['needs-triage']
64 });