diff --git a/.github/sync-with-template-delete.list b/.github/sync-with-template-delete.list new file mode 100644 index 00000000..0828ed8d --- /dev/null +++ b/.github/sync-with-template-delete.list @@ -0,0 +1 @@ +.github/workflows/auto-assign-issue.yml diff --git a/.github/workflows/auto-assign-issue.yml b/.github/workflows/auto-assign-issue.yml deleted file mode 100644 index 78b048f1..00000000 --- a/.github/workflows/auto-assign-issue.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Issue assignment - -on: - issues: - types: - - opened - - transferred - -jobs: - auto-assign: - runs-on: ubuntu-latest - steps: - - name: Auto-assign issue - uses: pozil/auto-assign-issue@v1 - with: - assignees: ${{secrets.DEFAULT_ISSUE_ASSIGNEE || 'remal'}} diff --git a/.github/workflows/auto-assign.yml b/.github/workflows/auto-assign.yml new file mode 100644 index 00000000..786b7fed --- /dev/null +++ b/.github/workflows/auto-assign.yml @@ -0,0 +1,57 @@ +name: Auto-assign issues or PRs + +on: + issues: + types: + - opened + - transferred + pull_request: + types: + - opened + +env: + DEFAULT_ASSIGNEE: ${{secrets.DEFAULT_ASSIGNEE || 'remal'}} + +permissions: + issues: write + pull-requests: write + +defaults: + run: + shell: bash + +jobs: + auto-assign: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Define assignee + id: assignee + uses: actions/github-script@v7 + with: + script: | + const repository = await github.rest.repos.get({ + owner: context.repo.owner, + repo: context.repo.repo, + }).then(it => it.data) + const isOrg = repository.owner.type == 'Organization' + if (!isOrg) { + core.setOutput('assignee', context.repo.owner) + return + } + + const defaultAssignee = '${{env.DEFAULT_ASSIGNEE}}' + const members = (await github.paginate(github.rest.orgs.listMembers, { + org: context.repo.owner, + })).filter(it => it.type === 'User').map(it => it.login) + if (members.includes(defaultAssignee)) { + core.setOutput('assignee', defaultAssignee) + return + } + + - name: Auto-assign ${{github.event == 'pull_request' && 'PR' || 'issue'}} + if: ${{steps.assignee.outputs.assignee}} + uses: pozil/auto-assign-issue@v1 + with: + assignees: ${{steps.assignee.outputs.assignee}} + abortIfPreviousAssignees: true diff --git a/.github/workflows/check-action-secrets.yml b/.github/workflows/check-action-secrets.yml index 00c4d265..a9724a88 100644 --- a/.github/workflows/check-action-secrets.yml +++ b/.github/workflows/check-action-secrets.yml @@ -19,7 +19,7 @@ jobs: check-action-secrets: name: Check action secrets runs-on: ubuntu-latest - timeout-minutes: 10 + timeout-minutes: 5 concurrency: group: check-action-secrets cancel-in-progress: true