diff --git a/.github/workflows/update-readme.yaml b/.github/workflows/update-readme.yaml new file mode 100644 index 0000000..4d58df9 --- /dev/null +++ b/.github/workflows/update-readme.yaml @@ -0,0 +1,35 @@ +name: Update README with Repo Size + +on: + push: + branches: + - main + +jobs: + update-readme: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Get Repository Size + id: repo-size + env: + GITHUB_TOKEN: ${{ secrets.PUBLIC_GITHUB_TOKEN }} + run: | + repo_size=$(curl -H "Authorization: token $GITHUB_TOKEN" \ + -s "https://api.github.com/repos/${{ github.repository }}" \ + | jq '.size') + echo "::set-output name=size::$repo_size" + + - name: Update README + id: update-readme + run: | + size_kb=${{ steps.repo-size.outputs.size }} + size_mb=$(echo "scale=2; $size_kb / 1024" | bc) + sed -i "s//${size_mb} MB/" README.md + + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: update README.md (automated) diff --git a/README.md b/README.md new file mode 100644 index 0000000..30cb79a --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +## Get repo size + +Open `wsl` under windows: + +```bash +curl -s -H "Authorization: token GITHUB_API_TOKEN" https://api.github.com/repos/trueberryless/htlkrems-school | jq '.size' | numfmt --to=iec --from-unit=1024 +``` + +![Static Badge](https://img.shields.io/badge/%3C!--%20REPO_SIZE%20--%3E?label=repo%20size)