Skip to content

Commit c4dcc1d

Browse files
authored
update config file (#588)
1 parent 34f6369 commit c4dcc1d

File tree

1 file changed

+29
-15
lines changed

1 file changed

+29
-15
lines changed

.github/workflows/label-on-approval.yml

+29-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Add Label on Approval
22

33
on:
4+
pull_request_target:
5+
types: [opened, synchronize]
46
pull_request_review:
57
types: [submitted]
68

@@ -9,17 +11,38 @@ permissions:
911
pull-requests: write
1012

1113
jobs:
14+
setup:
15+
if: github.event_name == 'pull_request_target'
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
with:
22+
ref: ${{ github.event.pull_request.head.ref }}
23+
repository: ${{ github.event.pull_request.head.repo.full_name }}
24+
25+
- name: Authenticate with GitHub App
26+
id: auth
27+
uses: tibdex/github-app-token@v2
28+
with:
29+
app_id: ${{ secrets.APP_ID }}
30+
private_key: ${{ secrets.PRIVATE_KEY }}
31+
1232
add-label:
33+
if: github.event_name == 'pull_request_review' && github.event.review.state == 'approved'
1334
runs-on: ubuntu-latest
1435

1536
steps:
37+
- name: Checkout code
38+
uses: actions/checkout@v4
39+
1640
- name: Authenticate with GitHub App
1741
id: auth
1842
uses: tibdex/github-app-token@v2
1943
with:
2044
app_id: ${{ secrets.APP_ID }}
2145
private_key: ${{ secrets.PRIVATE_KEY }}
22-
- run: "echo 'The created token is masked: ${{ steps.create_token.outputs.token }}'"
2346

2447
- name: Check if approval is from Collaborators
2548
id: check_approval
@@ -33,25 +56,16 @@ jobs:
3356
console.log('No review found.');
3457
return;
3558
}
36-
const collaborators = ['mxsm', 'TeslaRustor','SpaceXCN']; // Replace with actual GitHub usernames
37-
console.log('review:', review.state);
38-
console.log('review:', review.state === 'approved');
39-
console.log('Collaborators:', collaborators);
40-
console.log('Collaborators:', collaborators.includes(review.user.login));
59+
const collaborators = ['mxsm', 'TeslaRustor', 'SpaceXCN']; // Replace with actual GitHub usernames
60+
4161
// Check if the review is approved and from a collaborator
4262
const isApprovedByCollaborator = review.state === 'approved' && collaborators.includes(review.user.login);
43-
console.log('isApprovedByCollaborator:', isApprovedByCollaborator);
44-
console.log('pull_request:', pull_request.number);
45-
// Return the result to the workflow
46-
if (isApprovedByCollaborator) {
63+
64+
if (isApprovedByCollaborator) {
4765
await github.rest.issues.addLabels({
4866
owner,
4967
repo,
5068
issue_number: pull_request.number,
51-
labels: ['approved','auto merge']
69+
labels: ['approved', 'auto merge']
5270
});
5371
}
54-
55-
56-
57-

0 commit comments

Comments
 (0)