Skip to content

Commit

Permalink
Feat: Updated the workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Gyanthakur committed Oct 8, 2024
1 parent f8071b1 commit 26f0c4d
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions .github/workflows/autoLabling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ permissions:
pull-requests: write

on:
pull_request:
pull_request_target:
types:
- opened
issues:
Expand All @@ -21,15 +21,15 @@ jobs:
uses: actions/checkout@v4

- name: Add default labels to PRs
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request_target'
uses: actions/github-script@v6
with:
script: |
github.rest.issues.addLabels({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['Hactoberfest_2024', 'Hactoberfest-accepted', 'Hactoberfest']
labels: ['Hacktoberfest_2024', 'Hacktoberfest-accepted', 'Hacktoberfest']
})
- name: Add default labels to Issues
Expand All @@ -41,17 +41,15 @@ jobs:
issue_number: context.payload.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['Hactoberfest_2024', 'Hactoberfest-accepted', 'Hactoberfest']
labels: ['Hacktoberfest_2024', 'Hacktoberfest-accepted', 'Hacktoberfest']
})
label-prs:
runs-on: ubuntu-latest
outputs:
label: ${{ steps.set-label.outputs.label }}

steps:
- name: Determine PR Label
id: set-label
id: set-pr-label
run: |
if [[ "${{ github.event.pull_request.title }}" =~ bug ]]; then
echo "::set-output name=label::bug"
Expand All @@ -63,14 +61,23 @@ jobs:
echo "::set-output name=label::hacktoberfest"
fi
- name: Apply PR Label
uses: actions/github-script@v6
with:
script: |
github.rest.issues.addLabels({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['${{ steps.set-pr-label.outputs.label }}']
})
label-issues:
runs-on: ubuntu-latest
outputs:
label: ${{ steps.set-label.outputs.label }}

steps:
- name: Determine Issue Label
id: set-label
id: set-issue-label
run: |
if [[ "${{ github.event.issue.title }}" =~ bug ]]; then
echo "::set-output name=label::bug"
Expand All @@ -91,3 +98,14 @@ jobs:
elif [[ "${{ github.event.issue.title }}" =~ question ]]; then
echo "::set-output name=label::question"
fi
- name: Apply Issue Label
uses: actions/github-script@v6
with:
script: |
github.rest.issues.addLabels({
issue_number: context.payload.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['${{ steps.set-issue-label.outputs.label }}']
})

0 comments on commit 26f0c4d

Please sign in to comment.