Skip to content

Commit

Permalink
feat: add estimate review action
Browse files Browse the repository at this point in the history
Add GitHub Action for running the time needed for PR review estimation
  • Loading branch information
tnevrlka committed Feb 16, 2024
1 parent c4f9507 commit c84519e
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/estimate-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Estimate-review

on:
pull_request:

jobs:
estimate:
runs-on: ubuntu-latest
container:
image: golang:1.19

steps:
- name: Check out code
uses: actions/checkout@v4
with:
repository: 'redhat-appstudio/qe-tools'
- name: Setup Go environment
uses: actions/setup-go@v5

- name: Run estimate time needed for PR review
run: |
go run main.go estimate-review \
--owner ${{ github.repository_owner }} \
--repository ${{ github.event.repository.name }} \
--number ${{ github.event.pull_request.number }} \
> result
cat result
- name: Add label based on review time
run: |
reviewTime=$(cat result)
label="< 1 min"
if [ ${reviewTime} -gt 3600 ]; then
label="> 60 min"
elif [ ${reviewTime} -gt 1800 ]; then
label="30-60 min"
elif [ ${reviewTime} -gt 900 ]; then
label="15-30 min"
elif [ ${reviewTime} -gt 600 ]; then
label="10-15 min"
elif [ ${reviewTime} -gt 300 ]; then
label="5-10 min"
elif [ ${reviewTime} -gt 60 ]; then
label="1-5 min"
fi
echo "Adding label: ${label}"
curl -s --fail-with-body -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \
-d "[\"${label}\"]"

0 comments on commit c84519e

Please sign in to comment.