0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-28 09:16:49 +01:00
posthog/.github/workflows/report-pr-age.yml

42 lines
2.0 KiB
YAML
Raw Normal View History

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.repository == 'PostHog/posthog' && 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}}" }'
report-pr-as-annotation:
name: Report PR to PostHog
runs-on: ubuntu-20.04
if: github.repository == 'PostHog/posthog' && github.event.pull_request.merged == true
steps:
- name: Report PR to PostHog
uses: PostHog/posthog-annotate-merges-github-action@0.2.0
with:
posthog-token: ${{secrets.POSTHOG_PAUL_PERSONAL_API_KEY}}
posthog-project-id: ${{secrets.POSTHOG_PROJECT_ID}}
annotation-message: 'Merged PR #${{github.event.pull_request.number}} ${{github.event.pull_request.title}}'