diff --git a/.github/workflows/auto-label.yml b/.github/workflows/auto-label.yml index 6345941..b90dbcc 100644 --- a/.github/workflows/auto-label.yml +++ b/.github/workflows/auto-label.yml @@ -1,35 +1,46 @@ name: Auto Label PRs + on: pull_request: types: [opened, synchronize, reopened] + +permissions: + pull-requests: write + issues: write + jobs: labeler: runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Auto label PR - uses: actions/github-script@v4 + steps: + - name: Label PR based on files + uses: actions/github-script@v7 with: script: | - const pr = context.payload.pull_request; - const files = await github.paginate(github.rest.pulls.listFiles.endpoint.merge({ + const files = await github.rest.pulls.listFiles({ owner: context.repo.owner, repo: context.repo.repo, - pull_number: pr.number - })); - // On détermine les labels à appliquer en fonction des fichiers modifiés + pull_number: context.issue.number, + }); + const labels = new Set(); - files.forEach(file => { - if (file.filename.startsWith('front/')) labels.add('frontend'); - if (file.filename.startsWith('api/')) labels.add('backend'); - if (file.filename.endsWith('.md')) labels.add('documentation'); + + files.data.forEach(file => { + if (file.filename.startsWith("front/")) { + labels.add("frontend"); + } + if (file.filename.startsWith("api/")) { + labels.add("api"); + } + if (file.filename.endsWith(".md")) { + labels.add("documentation"); + } }); + if (labels.size > 0) { await github.rest.issues.addLabels({ owner: context.repo.owner, repo: context.repo.repo, - issue_number: pr.number, - labels: Array.from(labels) + issue_number: context.issue.number, + labels: [...labels], }); } diff --git a/front/README.md b/front/README.md index ddf636c..b1a204e 100644 --- a/front/README.md +++ b/front/README.md @@ -34,3 +34,5 @@ Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protrac ## Further help To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). + +## This is a small test for the label bot