-
-
Notifications
You must be signed in to change notification settings - Fork 40
112 lines (104 loc) · 4.48 KB
/
readme-badges.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Create Badges
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
#runs every day at midnight
schedule:
- cron: '0 0 * * *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
DATA_JSON_PATH: "./Packages/com.mattshark.openflight/Runtime/data.json"
jobs:
create-badge:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
#Put data extraction here
- name: Extract unique avatar count from data.json
uses: sergeysova/jq-action@v2
id: unique_avatar_count
with:
cmd: "jq '.Bases | length' $DATA_JSON_PATH"
- name: Extract total avatar count from data.json
uses: sergeysova/jq-action@v2
id: total_avatar_count
with:
cmd: "jq '[.Bases | to_entries[].value | to_entries[].value] | length' $DATA_JSON_PATH"
- name: Extract unique hash count from data.json
uses: sergeysova/jq-action@v2
id: unique_hash_count
with:
cmd: "jq '[.Bases | to_entries[].value | to_entries[].value.Hash[]] | length' $DATA_JSON_PATH"
- name: Count TODOs
id: count_todos
run: echo value=$(grep -rE "#TODO:|//TODO:" . | wc -l | awk '{print $1-1}') >> $GITHUB_OUTPUT #subtract 1 to account for the grep itself
- name: Current Release Downloads #use this api endpoint to get the latest release https://api.github.com/repos/Mattshark89/OpenFlight-VRC/releases?per_page=1
id: current_release_downloads
run: echo value=$(echo $(curl -s https://api.github.com/repos/Mattshark89/OpenFlight-VRC/releases) | jq -r 'map(select(.prerelease | not)) | first.assets[] | select(.name | endswith(".zip")) | .download_count') >> $GITHUB_OUTPUT
#run: echo value=$(echo $(curl -s https://api.github.com/repos/Mattshark89/OpenFlight-VRC/releases?per_page=1) | jq '.[0].assets[] | select(.name | endswith(".zip")) | .download_count') >> $GITHUB_OUTPUT
- name: Lifetime Release Downloads
id: lifetime_release_downloads
run: |
json=$(echo $(curl -s https://api.github.com/repos/Mattshark89/OpenFlight-VRC/releases))
totalDownloads=0
for row in $(echo "${json}" | jq -r '.[] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
assets=$(_jq '.assets[]')
downloads=$(echo $assets | jq 'select(.name | endswith(".zip")) | .download_count')
totalDownloads=$(($downloads + $totalDownloads))
done
echo value=$totalDownloads >> $GITHUB_OUTPUT
#Put badge creation here
- name: Create Unique Avatar Count Badge
uses: RubbaBoy/BYOB@v1.3.0
with:
NAME: unique_avatar_count
LABEL: 'Unique Supported Avatars'
STATUS: ${{ steps.unique_avatar_count.outputs.value }}
COLOR: blue
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Total Avatar Count Badge
uses: RubbaBoy/BYOB@v1.3.0
with:
NAME: total_avatar_count
LABEL: 'Total Supported Avatar Variations'
STATUS: ${{ steps.total_avatar_count.outputs.value }}
COLOR: blue
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Unique Hash Count Badge
uses: RubbaBoy/BYOB@v1.3.0
with:
NAME: unique_hash_count
LABEL: 'Unique Avatar Hashes'
STATUS: ${{ steps.unique_hash_count.outputs.value }}
COLOR: blue
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create TODO Count Badge
uses: RubbaBoy/BYOB@v1.3.0
with:
NAME: todo_count
LABEL: 'TODOs'
STATUS: ${{ steps.count_todos.outputs.value }}
COLOR: yellow
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Current Release Downloads Badge
uses: RubbaBoy/BYOB@v1.3.0
with:
NAME: current_release_downloads
LABEL: 'Current Release Downloads'
STATUS: ${{ steps.current_release_downloads.outputs.value }}
COLOR: green
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Lifetime Release Downloads Badge
uses: RubbaBoy/BYOB@v1.3.0
with:
NAME: lifetime_release_downloads
LABEL: 'LifeTime Release Downloads'
STATUS: ${{ steps.lifetime_release_downloads.outputs.value }}
COLOR: green
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}