Skip to content

Commit

Permalink
ci: convert issue metrics to use files rather than issues (#24)
Browse files Browse the repository at this point in the history
Signed-off-by: Tierney Cyren <[email protected]>
  • Loading branch information
bnb authored Apr 11, 2024
1 parent fd3ef4d commit 2b768ec
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 24 deletions.
35 changes: 23 additions & 12 deletions .github/workflows/issue-metrics-sendgrid-nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ on:
workflow_dispatch:
schedule:
- cron: '0 0 1 * *'

permissions:
issues: write
pull-requests: read

jobs:
build:
name: Issue Metrics (sendgrid/sendgrid-nodejs)
Expand All @@ -25,16 +20,32 @@ jobs:
#Set an environment variable with the date range
echo "$first_day..$last_day"
echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV"
- name: Checkout Repository
uses: actions/checkout@v4
- name: Run issue-metrics tool
uses: github/issue-metrics@v2
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SEARCH_QUERY: 'repo:sendgrid/sendgrid-nodejs is:issue created:${{ env.last_month }}'

- name: Create issue
uses: peter-evans/create-issue-from-file@v5
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'latest'
- name: Update npm
run: npm install -g npm
- name: Install dependencies
run: npm install
- name: Move Generated Metrics File to Storage
run: npm run convert:metrics:sendgrid-nodejs
- name: Run gr2m/create-or-update-pull-request
uses: gr2m/create-or-update-pull-request-action@v1 # Create a PR or update the Action's existing PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
title: Issue Metrics Report (sendgrid/sendgrid-nodejs)
token: ${{ secrets.GITHUB_TOKEN }}
content-filepath: ./issue_metrics.md
body: >
Monthly metrics report for sendgrid/sendgrid-nodejs, automatically generated with GitHub Actions.
branch: actions/metrics # Custom branch *just* for this Action.
commit-message: 'doc: generate metrics report for sendgrid/sendgrid-nodejs'
title: 'doc: generate metrics report'
assignees: bnb # change to whoever you want to be assigned to this PR
auto-merge: squash
32 changes: 23 additions & 9 deletions .github/workflows/issue-metrics-twilio-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Issue Metrics (twilio-node)
runs-on: ubuntu-latest
steps:
- name: Get dates for last month
- name: Get Dates for Last Month
shell: bash
run: |
# Calculate the first day of the previous month
Expand All @@ -25,16 +25,30 @@ jobs:
#Set an environment variable with the date range
echo "$first_day..$last_day"
echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV"
- name: Run issue-metrics tool
- name: Run issue-metrics Tool
uses: github/issue-metrics@v2
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SEARCH_QUERY: 'repo:twilio/twilio-node is:issue created:${{ env.last_month }}'

- name: Create issue
uses: peter-evans/create-issue-from-file@v5
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'latest'
- name: Update npm
run: npm install -g npm
- name: Install dependencies
run: npm install
- name: Move Generated Metrics File to Storage
run: npm run convert:metrics:twilio-node
- name: Run gr2m/create-or-update-pull-request
uses: gr2m/create-or-update-pull-request-action@v1 # Create a PR or update the Action's existing PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
title: Issue Metrics Report (twilio-node)
token: ${{ secrets.GITHUB_TOKEN }}
content-filepath: ./issue_metrics.md
body: >
Monthly metrics report for twilio/twilio-node, automatically generated with GitHub Actions.
branch: actions/metrics # Custom branch *just* for this Action.
commit-message: 'doc: generate metrics report for twilio/twilio-node'
title: 'doc: generate metrics report'
assignees: bnb # change to whoever you want to be assigned to this PR
auto-merge: squash
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"retro:twilio": "node utilities/retros/twilio.js",
"retro:twilio-labs": "node utilities/retros/twilio-labs.js",
"retro:twilio-samples": "node utilities/retros/twilio-samples.js",
"convert": "npm run convert:contributors",
"convert:contributors": "npm run convert:contributors:twilio && npm run convert:contributors:twilio-labs && npm run convert:contributors:twilio-samples",
"convert:contributors:twilio": "node utilities/convertContributors/twilio.js",
"convert:contributors:twilio-labs": "node utilities/convertContributors/twilio-labs.js",
"convert:contributors:twilio-samples": "node utilities/convertContributors/twilio-samples.js"
"convert:contributors:twilio-samples": "node utilities/convertContributors/twilio-samples.js",
"convert:metrics:sendgrid-nodejs": "node utilities/metrics/sendgrid-nodejs",
"convert:metrics:twilio-node": "node utilities/metrics/twilio-node"
},
"author": "Tierney Cyren <[email protected]> (https://twilio.com)",
"license": "MIT",
Expand Down
3 changes: 3 additions & 0 deletions reports/metrics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Repository Metrics

The contents of this directory are generated by a set of automation so we can better report on our open source repositories - specifically, this directory contains metrics about individual repositories we're tracking.
11 changes: 11 additions & 0 deletions utilities/metrics/sendgrid-nodejs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const convertToFileWithDate = require('../helpers/convertToFileWithDate')

async function convertMetrics () {
try {
await convertToFileWithDate('./issue_metrics.md', './reports/metrics', 'sendgrid-nodejs')
} catch (err) {
console.error(err)
}
}

convertMetrics()
11 changes: 11 additions & 0 deletions utilities/metrics/twilio-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const convertToFileWithDate = require('../helpers/convertToFileWithDate')

async function convertMetrics () {
try {
await convertToFileWithDate('./issue_metrics.md', './reports/metrics', 'twilio-node')
} catch (err) {
console.error(err)
}
}

convertMetrics()

0 comments on commit 2b768ec

Please sign in to comment.