Skip to content

Commit

Permalink
Added
Browse files Browse the repository at this point in the history
  • Loading branch information
Anjaliavv51 committed Aug 8, 2024
1 parent 596b428 commit 934f6bc
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions .github/workflows/auto-label-pr.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,38 @@
name: Add 'gssoc' label to PRs
name: Auto Label and Issue Check

on:
pull_request:
types: [opened,edited,synchronize]
types: [opened, edited, synchronize]

jobs:
add-gssoc-label:
auto-label-and-check:
runs-on: ubuntu-latest
steps:
- name: Add 'gssoc' label
uses: actions-ecosystem/action-add-labels@v1
- name: Add GSSoC Label and Check Issue
uses: actions/github-script@v6
with:
labels: gssoc
github_token: ${{ secrets.GITHUB_TOKEN }}
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { owner, repo } = context.repo;
const pr = context.payload.pull_request;
try {
await github.rest.issues.addLabels({
issue_number: pr.number,
owner: owner,
repo: repo,
labels: ['gssoc']
});
console.log('Added gssoc label');
} catch (error) {
console.error('Error adding gssoc label:', error);
}
const body = pr.body || '';
const issueMatch = body.match(/(?:close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)\s*:?\s*#(\d+)/i);
if (!issueMatch) {
core.setFailed('No related issue mentioned in the PR description. Please use the PR template and mention the related issue.');
} else {
console.log('Related issue found:', issueMatch[1]);
}

0 comments on commit 934f6bc

Please sign in to comment.