Sync labels to all cedanl repos #8
This file contains hidden or 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: Sync labels to all cedanl repos | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - '.github/labels.yml' | |
| workflow_dispatch: | |
| schedule: | |
| # Wekelijks op maandag om 6:00 UTC | |
| - cron: '0 6 * * 1' | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Sync labels to all repos | |
| env: | |
| GH_TOKEN: ${{ secrets.PROJECT_TOKEN }} | |
| run: | | |
| # Get all repos in cedanl org | |
| repos=$(gh repo list cedanl --json name --jq '.[].name') | |
| # Read labels from labels.yml as JSON array | |
| labels=$(yq eval -o=json '.' .github/labels.yml) | |
| for repo in $repos; do | |
| echo "Syncing labels to cedanl/$repo..." | |
| # Iterate over each label in the array | |
| echo "$labels" | jq -c '.[]' | while read -r label; do | |
| name=$(echo "$label" | jq -r '.name') | |
| color=$(echo "$label" | jq -r '.color') | |
| description=$(echo "$label" | jq -r '.description') | |
| echo " Creating/updating label: $name" | |
| gh label create "$name" \ | |
| --repo "cedanl/$repo" \ | |
| --color "$color" \ | |
| --description "$description" \ | |
| --force 2>/dev/null || true | |
| done | |
| done | |
| echo "Label sync complete!" |