diff --git a/.github/workflows/auto-assign-issues.yml b/.github/workflows/auto-assign-issues.yml index bb41420..24dac63 100644 --- a/.github/workflows/auto-assign-issues.yml +++ b/.github/workflows/auto-assign-issues.yml @@ -1,18 +1,15 @@ -name: Auto assignment for issues +name: "Auto assignment for issues" -on: - issues: - types: [opened] +on: issue_comment + +env: + GIHUB_TOKEN: ${{ secrets.BOT_ACCESS_TOKEN }} jobs: - auto-assign: - runs-on: ubuntu-latest - permissions: - issues: write - steps: - - name: 'Auto-assign issue' - uses: pozil/auto-assign-issue@v1 - with: - assignees: JamyGolden - numOfAssignee: 1 - allowSelfAssign: true + auto-assign: + runs-on: ubuntu-latest + steps: + - runs: echo "${{ env.BOT_ACCESS_TOKEN }}" + # uses: ./.github/workflows/auto-assign-parent.yml + # with: + # token: ${{ env.BOT_ACCESS_TOKEN }} diff --git a/.github/workflows/auto-assign-parent.yml b/.github/workflows/auto-assign-parent.yml new file mode 100644 index 0000000..45bd38f --- /dev/null +++ b/.github/workflows/auto-assign-parent.yml @@ -0,0 +1,56 @@ +name: "Auto assignment for issues" + +on: + workflow_call: + inputs: + token: + description: "GitHub Access Token" + type: string + required: true + +jobs: + auto-assign: + runs-on: "ubuntu-latest" + permissions: + issues: "write" + outputs: + codeowners: ${{ steps.codeowners.outputs.value }} + steps: + - name: "Check token value" + run: | + token="${{ inputs.token }}" + if [ -z "$token" ]; then + echo "'token' not provided." + exit 1 + fi + + - uses: actions/checkout@v4 + - name: "Get teams from CODEOWNERS file" + id: "codeowners" + run: | + result="" + first_item=true + + while IFS= read -r line; do + if [ "$first_item" = true ]; then + result="${line#* @tinted-theming/}" + first_item=false + else + result="$result, ${line#* @tinted-theming/}" + fi + done < .github/CODEOWNERS + + if [ -z "$result" ]; then + echo "Error: unable to determine teams from .github/CODEOWNERS file" + exit 1 + fi + + echo "value=$result" >> $GITHUB_OUTPUT + + - name: "Auto-assign issue" + uses: "pozil/auto-assign-issue@v2" + with: + repo-token: "${{ inputs.token }}" + teams: "${{ steps.codeowners.outputs.value }}" + numOfAssignee: 3 +