2023-09-20 15:59:12 +00:00
|
|
|
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
|
2024-03-04 12:54:02 +00:00
|
|
|
uses: actions/checkout@v4
|
2023-09-20 15:59:12 +00:00
|
|
|
with:
|
|
|
|
ref: master
|
|
|
|
|
|
|
|
- name: Query stats
|
2024-03-04 12:54:02 +00:00
|
|
|
uses: actions/github-script@v7
|
2023-09-20 15:59:12 +00:00
|
|
|
id: stats
|
|
|
|
with:
|
|
|
|
script: |
|
2023-09-20 16:15:35 +00:00
|
|
|
const query = `query($owner: String!, $name: String!) {
|
2023-09-20 15:59:12 +00:00
|
|
|
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;
|
|
|
|
});
|
2023-09-20 16:15:35 +00:00
|
|
|
|
|
|
|
console.log(formattedData);
|
2023-09-20 16:20:33 +00:00
|
|
|
|
2023-09-20 15:59:12 +00:00
|
|
|
return formattedData;
|
|
|
|
|
|
|
|
- name: Write stats
|
|
|
|
run: |
|
|
|
|
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
|
|
|
|
cat << $EOF > compat-stats.json
|
2023-09-20 16:15:35 +00:00
|
|
|
${{ steps.stats.outputs.result }}
|
2023-09-20 15:59:12 +00:00
|
|
|
$EOF
|
|
|
|
|
2023-10-20 13:01:56 +00:00
|
|
|
- name: Configure git
|
2023-09-20 15:59:12 +00:00
|
|
|
run: |
|
|
|
|
git config user.name github-actions[bot]
|
|
|
|
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
2023-10-20 13:01:56 +00:00
|
|
|
|
|
|
|
- name: Check if files have been modified
|
|
|
|
id: mod_check
|
|
|
|
run: |
|
2024-03-04 17:21:09 +00:00
|
|
|
[[ $(git status -s | wc -l) -lt 1 ]] \
|
2023-10-20 13:01:56 +00:00
|
|
|
&& echo "is-dirty=false" >> "$GITHUB_OUTPUT" \
|
|
|
|
|| echo "is-dirty=true" >> "$GITHUB_OUTPUT"
|
|
|
|
|
|
|
|
- name: Commit and push stats
|
|
|
|
if: steps.mod_check.outputs.is-dirty == 'true'
|
|
|
|
run: |
|
2023-09-20 15:59:12 +00:00
|
|
|
git add .
|
|
|
|
git commit -m "Update compat-stats.json"
|
|
|
|
git push
|