-
-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sachin Chaurasiya <[email protected]>
- Loading branch information
1 parent
aa63420
commit d2beb99
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |