0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-25 02:49:32 +01:00
posthog/.github/workflows/report-pr-age.yml
2024-09-25 09:11:38 -07:00

31 lines
1.4 KiB
YAML

name: Report PR Age
on:
pull_request:
types:
- closed
jobs:
report-pr-age:
name: Report age of PR
runs-on: ubuntu-20.04
if: github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.merged == true
steps:
- name: Calculate PR age
run: |
pr_age=$((($(date '+%s') - $(date -d "${{ github.event.pull_request.created_at }}" '+%s'))))
echo pr_age=$pr_age >> $GITHUB_ENV
first_commit_message_in_pr=$(curl -s "${{github.event.pull_request._links.commits.href}}" | jq '.[0].commit.message')
echo first_commit_message_in_pr=$first_commit_message_in_pr >> $GITHUB_ENV
if [[ $first_commit_message_in_pr =~ Revert[[:space:]] ]]; then
echo is_revert=true >> $GITHUB_ENV
else
echo is_revert=false >> $GITHUB_ENV
fi
- name: Capture PR age to PostHog
uses: PostHog/posthog-github-action@v0.1
with:
posthog-token: ${{secrets.POSTHOG_API_TOKEN}}
event: 'posthog-ci-pr-stats'
properties: '{"prAgeInSeconds": ${{ env.pr_age }}, "isRevert": ${{env.is_revert}}, "prTitle": "${{ github.event.pull_request.title}}", "prNumber": "${{ github.event.pull_request.number}}" }'