diff --git a/.github/workflows/label-sync.yml b/.github/workflows/label-sync.yml index d774d39..78c30db 100644 --- a/.github/workflows/label-sync.yml +++ b/.github/workflows/label-sync.yml @@ -1,75 +1,17 @@ -name: Reusable Label Sync +--- + +name: Label Sync + on: - workflow_call: - pull_request: - branches: - - main + schedule: + - cron: '0 6 * * Mon' # Weekly on Monday at 6 AM UTC + workflow_dispatch: + repository_dispatch: + types: [label-sync] + +permissions: + issues: write # Required to create and update labels jobs: label-sync: - runs-on: ubuntu-latest - steps: - - name: Determine repository type from custom properties - id: determine-type - run: | - # Fetch custom property from GitHub API - echo "Fetching repo type from custom properties..." - REPO_TYPE=$(gh api \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - "/repos/${{ github.repository }}/properties/values" \ - --jq '.[] | select(.property_name == "codebase_type") | .value' 2>/dev/null) - - if [ -z "$REPO_TYPE" ] || [ "$REPO_TYPE" = "null" ]; then - echo "No custom property 'codebase_type' found. Exiting workflow." - exit 1 - else - echo "Found custom property codebase_type: $REPO_TYPE" - fi - - echo "repo_type=$REPO_TYPE" >> $GITHUB_OUTPUT - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Determine config files - id: config - run: | - BASE_URL="https://raw.githubusercontent.com/brixion/.github/main/labels" - REPO_TYPE="${{ steps.determine-type.outputs.repo_type }}" - - # Always include general labels - CONFIG_FILES="$BASE_URL/general.yml" - - # Add type-specific labels if not general - case "$REPO_TYPE" in - "frontend") - CONFIG_FILES="$CONFIG_FILES"$'\n'"$BASE_URL/frontend.yml" - ;; - "backend") - CONFIG_FILES="$CONFIG_FILES"$'\n'"$BASE_URL/backend.yml" - ;; - "monorepo") - CONFIG_FILES="$CONFIG_FILES"$'\n'"$BASE_URL/frontend.yml"$'\n'"$BASE_URL/backend.yml" - ;; - *) - echo "Unknown repo type '$REPO_TYPE', using only general labels" - ;; - esac - - echo "Repository type: $REPO_TYPE" - echo "Config files to sync:" - echo "$CONFIG_FILES" - - # Format as multiline string for label-sync action - { - echo "config_files<> $GITHUB_OUTPUT - - - uses: EndBug/label-sync@v2 - with: - config-file: | - ${{ steps.config.outputs.config_files }} - token: ${{ secrets.GITHUB_TOKEN }} - delete-other-labels: false \ No newline at end of file + uses: brixion/.github/.github/workflows/label-sync.yml@main