Create Badges #1119
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |