Fix code scanning alert no. 13: Inefficient regular expression #45
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
name: Label Hacktoberfest PRs | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened, edited] | |
permissions: | |
pull-requests: write | |
issues: write | |
contents: write | |
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 }} |