Skip to content

Commit

Permalink
update config file (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsm authored Jun 15, 2024
1 parent 34f6369 commit c4dcc1d
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions .github/workflows/label-on-approval.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Add Label on Approval

on:
pull_request_target:
types: [opened, synchronize]
pull_request_review:
types: [submitted]

Expand All @@ -9,17 +11,38 @@ permissions:
pull-requests: write

jobs:
setup:
if: github.event_name == 'pull_request_target'
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Authenticate with GitHub App
id: auth
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.PRIVATE_KEY }}

add-label:
if: github.event_name == 'pull_request_review' && github.event.review.state == 'approved'
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Authenticate with GitHub App
id: auth
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.PRIVATE_KEY }}
- run: "echo 'The created token is masked: ${{ steps.create_token.outputs.token }}'"

- name: Check if approval is from Collaborators
id: check_approval
Expand All @@ -33,25 +56,16 @@ jobs:
console.log('No review found.');
return;
}
const collaborators = ['mxsm', 'TeslaRustor','SpaceXCN']; // Replace with actual GitHub usernames
console.log('review:', review.state);
console.log('review:', review.state === 'approved');
console.log('Collaborators:', collaborators);
console.log('Collaborators:', collaborators.includes(review.user.login));
const collaborators = ['mxsm', 'TeslaRustor', 'SpaceXCN']; // Replace with actual GitHub usernames
// Check if the review is approved and from a collaborator
const isApprovedByCollaborator = review.state === 'approved' && collaborators.includes(review.user.login);
console.log('isApprovedByCollaborator:', isApprovedByCollaborator);
console.log('pull_request:', pull_request.number);
// Return the result to the workflow
if (isApprovedByCollaborator) {
if (isApprovedByCollaborator) {
await github.rest.issues.addLabels({
owner,
repo,
issue_number: pull_request.number,
labels: ['approved','auto merge']
labels: ['approved', 'auto merge']
});
}

0 comments on commit c4dcc1d

Please sign in to comment.