Skip to content

Robust enterprise config: env-first, auto_create default true, simpli… #1

Robust enterprise config: env-first, auto_create default true, simpli…

Robust enterprise config: env-first, auto_create default true, simpli… #1

name: GitHub Copilot Cost Center Automation
on:
schedule:
# Run every 6 hours (adjust as needed)
- cron: '0 */6 * * *'
# Allow manual triggering from GitHub UI
workflow_dispatch:
inputs:
mode:
description: 'Run mode'
required: true
default: 'incremental'
type: choice
options:
- incremental
- full
jobs:
update-cost-centers:
runs-on: ubuntu-latest
env:
GITHUB_ENTERPRISE: ${{ secrets.GITHUB_ENTERPRISE_NAME }}
GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: pip install -r requirements.txt
- name: (Optional) Show effective config (debug)
run: |
echo "Enterprise: $GITHUB_ENTERPRISE"
grep enterprise config/config.yaml || true
python - <<'PY'
import os, yaml

Check failure on line 45 in .github/workflows/cost-center-automation.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/cost-center-automation.yml

Invalid workflow file

You have an error in your yaml syntax on line 45
with open('config/config.yaml') as f:
data = yaml.safe_load(f) or {}
print('YAML enterprise:', data.get('github', {}).get('enterprise'))
print('ENV enterprise:', os.getenv('GITHUB_ENTERPRISE'))
PY
- name: Run incremental cost center update
if: github.event.inputs.mode != 'full'
run: |
python main.py --create-cost-centers --assign-cost-centers --incremental --mode apply --yes --summary-report --verbose
- name: Run full cost center update
if: github.event.inputs.mode == 'full'
run: |
python main.py --create-cost-centers --assign-cost-centers --mode apply --yes --summary-report --verbose
- name: Upload logs
if: always()
uses: actions/upload-artifact@v4
with:
name: cost-center-logs-${{ github.run_number }}
path: logs/
retention-days: 30
- name: Check for failures and notify
if: failure()
run: |
echo "::error::Cost center automation failed. Check the logs for details."