Automatic stats

This commit is contained in:
Isaac Marovitz 2023-07-12 19:35:26 +01:00
parent 6b474a57d4
commit 2636db0f19
No known key found for this signature in database
GPG key ID: 97250B2B09A132E1

57
.github/workflows/label-stats.yml vendored Normal file
View file

@ -0,0 +1,57 @@
name: Generate label stats
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
stats:
name: Generate label stats
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Query stats
uses: actions/github-script@v6
id: stats
with:
result-encoding: string
script: |
const query = `query($owner: String!, $name: String!) {
repository(owner: $owner, name: $name) {
labels(first: 100, query: "status") {
nodes {
name
issues {
totalCount
}
}
}
}
}`;
const variables = {
owner: context.repo.owner,
name: context.repo.repo,
}
const result = await github.graphql(query, variables)
const labelsWithIssueCount = result.repository.labels.nodes;
const formattedData = {};
labelsWithIssueCount.forEach((label) => {
formattedData[label.name] = label.issues.totalCount;
});
const string = JSON.stringify(formattedData, null, 2).replaceAll('\"', '\\"');
return string;
- name: Write stats
run: echo "${{steps.stats.outputs.result}}" > compat-stats.json
- name: Commit stats
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "Update stats"
git push