apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
  generateName: pullrequest-
spec:
  resources:
    inputs:
    - name: pr
      resourceSpec:
        type: pullRequest
        params:
        - name: url
          # I just picked a random PR. The first couple didn't have any interesting comments or labels.
          value: https://github.com/tektoncd/pipeline/pull/100
  taskSpec:
    resources:
      inputs:
      - name: pr
        type: pullRequest
    steps:
    - name: dump-workspace
      image: ubuntu
      script: find $(resources.inputs.pr.path)/* -type f | xargs tail -n +1

    - name: ensure-approved
      image: ubuntu
      script: |
        if [ -f "$(resources.inputs.pr.path)/labels/approved" ]; then
          echo "PR is approved!"
        else
          echo "PR is not approved!"
          exit 1
        fi
