This tool calculate GitHub Actions usage with specified repository and period.
You can choose between GitHub Actions and Command Line to exec this tool.
Warning
This tool can only calculate the usage of less than 1000 workflow runs
(due to GitHub REST API limitations).
So, please change period by workflow run count.
You can see workflow run count with follow command.
./ghausage count --repo REPO --start START_DATE --end END_DATE
# example)
./ghausage count --repo muno92/gha-usage --start 2022-11-01 --end 2022-11-30
From GitHub Actions, gha-usage output result to Job Summary.
- sub-command
Subcommand of ghausage. [ sum | count ] - repo (required)
The name of target repository.
example) muno92/gha-usage - start-date (required)
Start date of calculation period with format 'yyyy-mm-dd'.
example) 2022-01-01 - end-date (required)
Start date of calculation period with format 'yyyy-mm-dd'.
example) 2022-01-31
name: Calculate usage
on:
schedule:
- cron: '5 0 1 * *'
jobs:
calc-usage:
runs-on: ubuntu-latest
steps:
- name: Set Start Date
run: echo "START_DATE=$(date -d "$(date +'%Y%m01') 1 month ago" +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Set End Date
run: echo "END_DATE=$(date -d "$(date +'%Y%m01') 1 days ago" +'%Y-%m-%d')" >> $GITHUB_ENV
- uses: muno92/gha-usage@v1
with:
repo: ${{ github.repository }}
start-date: ${{ env.START_DATE }}
end-date: ${{ env.END_DATE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: Calculate usage
on:
schedule:
- cron: '5 0 * * 0'
jobs:
calc-usage:
runs-on: ubuntu-latest
steps:
- name: Set Start Date
run: echo "START_DATE=$(date -d '8 days ago' +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Set End Date
run: echo "END_DATE=$(date -d '1 days ago' +'%Y-%m-%d')" >> $GITHUB_ENV
- uses: muno92/gha-usage@v1
with:
repo: ${{ github.repository }}
start-date: ${{ env.START_DATE }}
end-date: ${{ env.END_DATE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- Download binary from release page.
- Creating a personal access token.
When target repository is public, token needs no permission, because token is only for avoid rate limit. - Exec gha-usage
export GITHUB_TOKEN=YOUR_TOKEN ./ghausage sum --repo REPO --start START_DATE --end END_DATE # example) ./ghausage sum --repo muno92/gha-usage --start 2022-11-01 --end 2022-11-30