Skip to content

πŸš€ GitHub Actions usage report (sbom) #87

πŸš€ GitHub Actions usage report (sbom)

πŸš€ GitHub Actions usage report (sbom) #87

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