Script to setup Windows 10 1903
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.1 KiB

name: Badge
on:
push:
2 years ago
branches:
- master
2 years ago
# tags:
# - '*.*.*'
2 years ago
pull_request:
branches:
- master
jobs:
update-badges:
name: Update Badges
runs-on: windows-latest
steps:
- name: Checkout Repository
uses: actions/checkout@main
2 years ago
- name: Download cloc
run: |
2 years ago
$Token = "${{ secrets.GITHUB_TOKEN }}"
$Headers = @{
Accept = "application/json"
Authorization = "Bearer $Token"
}
$Parameters = @{
Uri = "https://api.github.com/repos/AlDanial/cloc/releases/latest"
Headers = $Headers
UseBasicParsing = $true
Verbose = $true
}
$Tag = (Invoke-RestMethod @Parameters).tag_name.replace("v", "")
$Parameters = @{
Uri = "https://github.com/AlDanial/cloc/releases/download/v$Tag/cloc-$Tag.exe"
OutFile = "$PSScriptRoot\cloc.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
- name: Get the Numbers
run: |
2 years ago
$JSON = & "$PSScriptRoot\cloc.exe" "src\Sophia_Script_for_Windows_11\Module\Sophia.psm1" --json | ConvertFrom-Json
$blank = $JSON.SUM.blank
$comment = $JSON.SUM.comment
$code = $JSON.SUM.code
2 years ago
# "$((($blank + $comment + $code)/1000).ToString("#.#").replace(",", "."))k"
$Summary = ("{0:N1}k" -f (($blank + $comment + $code)/1000)).replace(",", ".")
2 years ago
Write-Verbose -Message ($blank + $comment + $code) -Verbose
echo "CODE_LINES=$Summary" >> $env:GITHUB_ENV
- name: Writing to Gist
uses: schneegans/dynamic-badges-action@master
with:
auth: ${{ secrets.GIST_SophiaScript }}
gistID: 9852d6b9569a91bf69ceba8a94cc97f4
filename: SophiaScript.json
label: Lines of Code
message: ${{ env.CODE_LINES }}
namedLogo: PowerShell
color: brightgreen