Skip to content

Commit

Permalink
When a PR comes from a fork we shouldn't add labels (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
GordonBeeming authored Sep 13, 2023
1 parent 9a7a814 commit 09a79a0
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions .github/workflows/pr-manage-stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,31 @@ jobs:
new_pull_request:
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
steps:
- name: add labels
uses: actions-ecosystem/action-add-labels@v1
with:
labels: |
Age: 🥚 - New
steps:
- name: Checkout
uses: actions/checkout@v3

- name: add label
shell: pwsh
run: |
$thisPr = gh pr view ${{ github.event.pull_request.number }} --json number,isCrossRepository | ConvertFrom-Json
if ($thisPr.isCrossRepository) {
Write-Output "Skipping cross repository PR"
return
}
# ensure labels exist - create them if they don't
# https://docs.github.com/en/rest/reference/issues#create-a-label
$label = "Age: 🥚 - New"
$description = "About 2 hours old"
Write-Output "Ensuring label exists: $label ($description))"
gh api repos/${{ github.repository }}/labels -f name="$label" -f color=000000 -f description="$description"
Write-Output "Adding label: $label"
gh pr edit $thisPr.number --add-label "$label"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


scheduled_run:
if: ${{ github.event_name != 'pull_request' }}
Expand Down Expand Up @@ -102,6 +121,10 @@ jobs:
}
$newLabel = $labels[$ageAsPoints - 1]
$labelExists = $prLabels | Where-Object { $_.name -eq $newLabel }
if ($labelExists) {
return
}
Write-Output "Adding label: $newLabel"
# all labels except the new label
Expand All @@ -111,7 +134,7 @@ jobs:
gh pr edit $number --add-label "$newLabel" --remove-label "$allLabels"
Write-Output ""
if ($ageInHours -ge 36 -and $ageInHours -lt 38 -and $author.is_bot -eq $false) { # after 36 hours old
if ($ageInHours -eq 36 -and $author.is_bot -eq $false) { # 36 hours old
$comment = @"
Howzit @$($author.login),
Expand All @@ -128,4 +151,4 @@ jobs:
}
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 09a79a0

Please sign in to comment.