Skip to content

Commit

Permalink
Create label-hacktoberfest.yml
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Chaurasiya <[email protected]>
  • Loading branch information
Sachin-chaurasiya authored Sep 24, 2024
1 parent aa63420 commit d2beb99
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/label-hacktoberfest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Label Hacktoberfest PRs

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

permissions:
pull-requests: write
issues: read
contents: read

jobs:
label-hacktoberfest:
runs-on: ubuntu-latest

steps:
- name: Check out the repository
uses: actions/checkout@v3

- name: Get linked issue number from PR body
id: issue-number
run: |
issue_number=$(echo "${{ github.event.pull_request.body }}" | grep -oE '#[0-9]+' | head -n 1 | tr -d '#')
echo "Linked issue number: $issue_number"
echo "issue_number=$issue_number" >> $GITHUB_ENV
- name: Check if linked issue has "hacktoberfest" label
id: check-hacktoberfest-label
run: |
if [ -n "${{ env.issue_number }}" ]; then
labels=$(gh issue view ${{ env.issue_number }} --json labels --jq '.labels[].name')
echo "Labels on linked issue: $labels"
if [[ "$labels" == *"hacktoberfest"* ]]; then
echo "Linked issue has 'hacktoberfest' label"
echo "label-hacktoberfest=true" >> $GITHUB_ENV
else
echo "label-hacktoberfest=false" >> $GITHUB_ENV
fi
else
echo "No linked issue found"
echo "label-hacktoberfest=false" >> $GITHUB_ENV
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Add "hacktoberfest" label to PR if linked issue has it
if: env.label-hacktoberfest == 'true'
uses: actions-ecosystem/action-add-labels@v1
with:
labels: hacktoberfest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit d2beb99

Please sign in to comment.