Skip to content

Organization License Check #12

Organization License Check

Organization License Check #12

name: Organization License Check
on:
schedule:
- cron: '0 */24 * * *' # Runs every 12 hours
workflow_dispatch:
permissions:
contents: write
issues: write
actions: read
jobs:
check-licenses:
runs-on: ubuntu-latest
steps:
- name: Checkout Org .github Repo
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/.github
token: ${{ secrets.ORG_GITHUB_TOKEN }} # Use token to access private repo
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install PyGithub
- name: Run License Check Script
env:
ORG_TOKEN: ${{ secrets.ORG_GITHUB_TOKEN }}
EXCLUDED_REPOS: ${{ vars.EXCLUDED_REPOS }}
run: |
python .github/scripts/check_licenses.py
- name: Create Summary Issue
if: failure()
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const results = JSON.parse(fs.readFileSync('scan_results.json', 'utf8'));
const body = `
# License Compliance Scan Results
## Non-Permissive License Repositories:
${results.non_permissive.map(item => `- ${item.repo}: ${item.reason}`).join('\n')}
## CLA Trigger Installation Status:
CLA trigger installed in:
${results.trigger_installed.map(repo => `- ${repo}`).join('\n')}
## Excluded Repositories:
${results.excluded.map(repo => `- ${repo}`).join('\n')}
${results.errors.length ? `## Errors:
${results.errors.map(error => `- ${error}`).join('\n')}` : ''}
`;
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'License Compliance Scan Results',
body: body,
labels: ['license-compliance']
});