Skip to content

Update and rename Binary_search.cpp to Update BinarySearch.md #26

Update and rename Binary_search.cpp to Update BinarySearch.md

Update and rename Binary_search.cpp to Update BinarySearch.md #26

name: PR Follow and Star Check
on:
pull_request:
types: [opened, reopened]
jobs:
check-follow-and-star:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Check if user is following
id: check-follow
uses: actions/github-script@v6
with:
script: |
const { github, context } = require('@actions/github');
const owner = context.repo.owner;
const prAuthor = context.payload.pull_request.user.login;
const result = await github.rest.users.checkFollowing({
username: prAuthor,
target_user: owner
});
return result.data;
- name: Check if user has starred the repository
id: check-star
uses: actions/github-script@v6
with:
script: |
const { github, context } = require('@actions/github');
const owner = context.repo.owner;
const repo = context.repo.repo;
const prAuthor = context.payload.pull_request.user.login;
try {
const result = await github.rest.activity.getRepoSubscription({
owner: owner,
repo: repo,
username: prAuthor
});
return result.data.subscribed;
} catch (error) {
return false; // User hasn't starred the repo
}
- name: Set check status and leave comment
uses: actions/github-script@v6
with:
script: |
const { github, context } = require('@actions/github');
const isFollowing = steps['check-follow'].outputs.result;
const hasStarred = steps['check-star'].outputs.result;
if (isFollowing && hasStarred) {
await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'Follow and Star Check',
head_sha: context.payload.pull_request.head.sha,
status: 'completed',
conclusion: 'success',
output: {
title: 'Success',
summary: 'User is following and has starred the repository.'
}
});
} else {
await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'Follow and Star Check',
head_sha: context.payload.pull_request.head.sha,
status: 'completed',
conclusion: 'failure',
output: {
title: 'Failure',
summary: 'User must follow and star the repository to proceed.'
}
});
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: 'Please follow and star the repository to proceed with your pull request.'
});
}