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
Paul D'Ambra 7187355236
feat: use annotation creation type (#14156)
* feat: use annotation creation type

* show Github on annotation card as well

* use version of the github action that sends creation_type

* ts fangling for tests

* Update frontend/src/scenes/annotations/Annotations.tsx

Co-authored-by: Michael Matloka <dev@twixes.com>

* don't add fake email

* show a nice profile pic for bots

* only one type at a time

* icon source

---------

Co-authored-by: Michael Matloka <dev@twixes.com>
2023-02-09 20:23:21 +00:00

42 lines
2.0 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.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}}'