-
Notifications
You must be signed in to change notification settings - Fork 7
79 lines (67 loc) · 2.11 KB
/
label-stats.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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@v4
with:
ref: master
- name: Query stats
uses: actions/github-script@v7
id: stats
with:
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;
});
console.log(formattedData);
return formattedData;
- name: Write stats
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
cat << $EOF > compat-stats.json
${{ steps.stats.outputs.result }}
$EOF
- name: Configure git
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- name: Check if files have been modified
id: mod_check
run: |
[[ $(git status -s | wc -l) -lt 1 ]] \
&& 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: |
git add .
git commit -m "Update compat-stats.json"
git push