π GitHub Actions usage report (sbom) #87
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: π GitHub Actions usage report (sbom) | |
on: | |
workflow_dispatch: | |
schedule: | |
# Runs at 00:50 UTC on the first of every week (Monday) | |
# | |
# ββββββββββββββββ minute | |
# β βββββββββββββ hour | |
# β β βββββββββββ day (month) | |
# β β β βββββββββ month | |
# β β β β βββββββ day (week) | |
- cron: '50 0 * * 1' | |
jobs: | |
count-by-action: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: joshjohanning/github-misc-scripts | |
path: github-misc-scripts | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ vars.APP_ID }} | |
private-key: ${{ secrets.PRIVATE_KEY }} | |
- name: run actions export | |
run: | | |
./github-misc-scripts/gh-cli/get-actions-usage-in-organization.sh ${{ github.repository_owner }} count-by-action md > count-by-action.md | |
env: | |
GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
- name: output csv | |
run: | | |
cat count-by-action.md | |
# redirect to job summary | |
- name: upload job summary | |
run: | | |
echo "# ππ Actions Report for org" >> $GITHUB_STEP_SUMMARY | |
cat count-by-action.md >> $GITHUB_STEP_SUMMARY | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: count-by-action | |
path: count-by-action.md | |
count-by-version: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: joshjohanning/github-misc-scripts | |
path: github-misc-scripts | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ vars.APP_ID }} | |
private-key: ${{ secrets.PRIVATE_KEY }} | |
- name: run actions export | |
run: | | |
./github-misc-scripts/gh-cli/get-actions-usage-in-organization.sh ${{ github.repository_owner }} count-by-version md > count-by-version.md | |
env: | |
GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
- name: output md | |
run: | | |
cat count-by-version.md | |
# redirect to job summary | |
- name: upload job summary | |
run: | | |
echo "# ππ Actions Report for org" >> $GITHUB_STEP_SUMMARY | |
cat count-by-version.md >> $GITHUB_STEP_SUMMARY | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: count-by-version | |
path: count-by-version.md | |
commit-to-repo: | |
runs-on: ubuntu-latest | |
needs: [count-by-action, count-by-version] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v3 | |
- name: push to git repo | |
run: | | |
mv count-by-action/count-by-action.md count-by-action.md | |
mv count-by-version/count-by-version.md count-by-version.md | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git add count-by-version.md count-by-action.md | |
git commit -m "updating organization actions reports (sbom)" | |
git push |