diff --git a/.github/workflows/auto-assign-core-team.yml b/.github/workflows/auto-assign-core-team.yml new file mode 100644 index 00000000000..19331d9bd67 --- /dev/null +++ b/.github/workflows/auto-assign-core-team.yml @@ -0,0 +1,72 @@ +name: Auto-assign PRs to core team authors + +on: + pull_request_target: + types: [opened, reopened, ready_for_review, converted_to_draft] + +permissions: + pull-requests: write + contents: read + +jobs: + auto_assign: + name: Assign PR author when core team member + runs-on: ubuntu-latest + steps: + - name: Check team membership via REST + id: team + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ORG: QwikDev + TEAM_SLUG: qwik-team + AUTHOR: ${{ github.event.pull_request.user.login }} + run: | + RESPONSE=$(curl -s \ + -H "Authorization: token ${GH_TOKEN}" \ + -H "Accept: application/vnd.github+json" \ + "https://api.github.com/orgs/${ORG}/teams/${TEAM_SLUG}/memberships/${AUTHOR}") + + STATE=$(echo "$RESPONSE" | jq -r '.state // empty') + if [ "$STATE" = "active" ]; then + echo "isCore=true" >> $GITHUB_OUTPUT + else + echo "isCore=false" >> $GITHUB_OUTPUT + fi + + - name: Assign PR to author + if: steps.team.outputs.isCore == 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PR_NUMBER=${{ github.event.pull_request.number }} + AUTHOR=${{ github.event.pull_request.user.login }} + curl -s -H "Authorization: token ${GH_TOKEN}" \ + -H "Accept: application/vnd.github+json" \ + -X POST \ + -d "{\"assignees\":[\"${AUTHOR}\"]}" \ + https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/assignees + + - name: Add PR to Qwik Development project + if: steps.team.outputs.isCore == 'true' + uses: actions/add-to-project@v0.6.1 + with: + project-url: https://github.com/orgs/QwikDev/projects/1 + github-token: ${{ secrets.QWIK_API_TOKEN_GITHUB }} + + - name: Ensure project + set Status to "In progress" (draft) + if: steps.team.outputs.isCore == 'true' && github.event.pull_request.draft == true + uses: actions/add-to-project@v0.6.1 + with: + project-url: https://github.com/orgs/QwikDev/projects/1 + github-token: ${{ secrets.QWIK_API_TOKEN_GITHUB }} + fields: | + Status: In progress + + - name: Ensure project + set Status to "Waiting For Review" (ready) + if: steps.team.outputs.isCore == 'true' && github.event.pull_request.draft == false + uses: actions/add-to-project@v0.6.1 + with: + project-url: https://github.com/orgs/QwikDev/projects/1 + github-token: ${{ secrets.QWIK_API_TOKEN_GITHUB }} + fields: | + Status: Waiting For Review \ No newline at end of file