Skip to content

Commit

Permalink
Merge pull request #1235 from flatcar/t-lo/add-contrib-issue-pr-metrics
Browse files Browse the repository at this point in the history
workflows: add monthly activity / contributor status report
  • Loading branch information
t-lo authored Nov 8, 2023
2 parents b176ef0 + 3be0d9f commit f9cf9ba
Showing 1 changed file with 106 additions and 0 deletions.
106 changes: 106 additions & 0 deletions .github/workflows/issue-pr-contrib-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Monthly contributor report
on:
workflow_dispatch:
inputs:
start_date:
type: string
description: |
Custom start date for metrics generation in YYYY-MM-DD format.
required: true
end_date:
type: string
description: |
Custom end date for metrics generation in YYYY-MM-DD format.
required: true
# Run on every 22th of the month. This guarantees that this action runs
# before the Dev Sync (every 4th Tuesday of the month in the afternoon).
schedule:
- cron: '0 0 22 * *'

permissions:
issues: write

jobs:
contributor_report:
name: contributor report
runs-on: ubuntu-latest

steps:
- name: Set the start and end dates
shell: bash
run: |
set -euo pipefail
if [[ -n "${{inputs.start_date}}" && -n "${{inputs.end_date}}" ]] ; then
start_date="${{inputs.start_date}}"
end_date=${{inputs.end_date}}
fi
# This runs at midnight so metrics from the previous month's 22nd are not included
# in the prev month's stats.
start_date=$(date -d "last month" +%Y-%m-22)
end_date=$(date -d "today" +%Y-%m-22)
#Set an environment variable with the date range
echo "START_DATE=$start_date" >> "$GITHUB_ENV"
echo "END_DATE=$end_date" >> "$GITHUB_ENV"

- name: Collect contributor metrics
uses: github/contributors@v1
env:
GH_TOKEN: ${{ secrets.GH_ACTION_METRICS_ORG_READ }}
START_DATE: ${{ env.START_DATE }}
END_DATE: ${{ env.END_DATE }}
# We explicitly list repos for our metrics here so temporary forks like
# e.g. systemd, gentoo, or udev don't pollute the stats
REPOSITORY: "flatcar/nebraska,flatcar/flatcar-website,flatcar/flatcar-build-script,flatcar/baselayout,flatcar/bootengine,flatcar/coreos-cloudinit,flatcar/flatcar-dev-util,flatcar/init,flatcar/locksmith,flatcar/mantle,flatcar/mayday,flatcar/nss-altfiles,flatcar/scripts,flatcar/seismograph,flatcar/shim,flatcar/sysroot-wrappers,flatcar/toolbox,flatcar/torcx,flatcar/update-ssh-keys,flatcar/update_engine,flatcar/updateservicectl,flatcar/Flatcar,flatcar/flatcar-packer-qemu,flatcar/flatcar-ipxe-scripts,flatcar/flatcar-cloud-image-uploader,flatcar/flatcar-linux-update-operator,flatcar/flatcar-release-mirror,flatcar/flatcar-terraform,flatcar/sdnotify-proxy,flatcar/flatcar-automation,flatcar/nebraska-update-agent,flatcar/fleetlock,flatcar/flog,flatcar/ign-converter,flatcar/nomad-on-flatcar,flatcar/sysext-bakery,flatcar/reports,flatcar/flatcar-demos,flatcar/jitsi-server,flatcar/flatcar-mastodon,flatcar/ue-rs,flatcar/azure-marketplace-ingestion-api"
SPONSOR_INFO: "false"

- name: Collect PR metrics
uses: github/issue-metrics@v2
env:
GH_TOKEN: ${{ secrets.GH_ACTION_METRICS_ORG_READ }}
SEARCH_QUERY: 'org:flatcar is:pr created:${{ env.START_DATE }}..${{ env.END_DATE }}'

- name: rename PR metrics file
shell: bash
run: |
set -euo pipefail
mv issue-metrics.md pr-metrics.md
- name: Collect discussion metrics
uses: github/issue-metrics@v2
env:
GH_TOKEN: ${{ secrets.GH_ACTION_METRICS_ORG_READ }}
SEARCH_QUERY: 'org:flatcar type:discussion created:${{ env.START_DATE }}..${{ env.END_DATE }}'

- name: rename discussion metrics file
shell: bash
run: |
set -euo pipefail
mv issue-metrics.md discussion-metrics.md
- name: Collect issue metrics
uses: github/issue-metrics@v2
env:
GH_TOKEN: ${{ secrets.GH_ACTION_METRICS_ORG_READ }}
SEARCH_QUERY: 'org:flatcar is:issue created:${{ env.START_DATE }}..${{ env.END_DATE }}'

- name: Assemble full report
shell: bash
run: |
set -euo pipefail
mv contributors.md report.md
echo -e "\n\n# Discussions Metrics" >> report.md
tail --lines=+2 discussion-metrics.md >> report.md
# issues already have the correct headline
cat issue-metrics.md >> report.md
echo -e "\n\n# Pull Requests Metrics" >> report.md
tail --lines=+2 pr-metrics.md >> report.md
- name: Create issue
uses: peter-evans/create-issue-from-file@v4
with:
title: Monthly contributions report ${{ env.START_DATE }} - ${{ env.END_DATE }}
token: ${{ secrets.GITHUB_TOKEN }}
content-filepath: ./report.md
labels: kind/metric

0 comments on commit f9cf9ba

Please sign in to comment.