name: Detect PR Pipeline Type on: pull_request: branches: [main, dev, uat] workflow_call: permissions: contents: read pull-requests: write jobs: test-detection-logic: runs-on: ubuntu-latest timeout-minutes: 2 steps: - name: Checkout uses: actions/checkout@v6 - name: Run detection tests run: bash scripts/test-detect-pipeline.sh detect-pipeline: runs-on: ubuntu-latest timeout-minutes: 5 outputs: pipeline-type: ${{ steps.detect.outputs.pipeline-type }} steps: - name: Checkout uses: actions/checkout@v6 with: fetch-depth: 0 - name: Get changed files id: changed-files uses: tj-actions/changed-files@v47 with: files_separator: '\n' - name: Detect pipeline type id: detect run: | echo "Changed files:" echo "${{ steps.changed-files.outputs.all_changed_files }}" pipeline=$(echo "${{ steps.changed-files.outputs.all_changed_files }}" | bash scripts/detect-pipeline.sh) echo "pipeline-type=$pipeline" >> $GITHUB_OUTPUT echo "Detected pipeline: $pipeline" - name: Set PR label if: github.event_name == 'pull_request' env: GH_TOKEN: ${{ github.token }} REPO: ${{ github.repository }} PR_NUMBER: ${{ github.event.pull_request.number }} PIPELINE_TYPE: ${{ steps.detect.outputs.pipeline-type }} run: | curl -sf \ -X POST \ -H "Authorization: Bearer ${GH_TOKEN}" \ -H "Accept: application/vnd.github.v3+json" \ "https://api.github.com/repos/${REPO}/issues/${PR_NUMBER}/labels" \ -d "{\"labels\":[\"${PIPELINE_TYPE}\"]}"