diff --git a/.github/workflows/label-preview-pr.yml b/.github/workflows/label-preview-pr.yml new file mode 100644 index 0000000000..ee35567228 --- /dev/null +++ b/.github/workflows/label-preview-pr.yml @@ -0,0 +1,32 @@ +name: Label Preview Pull Requests + +on: + pull_request_target: + types: [opened] + branches: [preview] + +permissions: + contents: read + pull-requests: write + +jobs: + label: + runs-on: ubuntu-latest + steps: + - name: Add preview labels + uses: actions/github-script@v7 + with: + script: | + const authorAssociation = context.payload.pull_request.author_association; + const labels = ['preview']; + + if (['MEMBER', 'OWNER'].includes(authorAssociation)) { + labels.push('gsd:50917'); + } + + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + labels, + });