This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Labelling when code review completed | ||
on: | ||
pull_request: | ||
branches: | ||
- dev | ||
jobs: | ||
if: false | ||
labelling: | ||
## if: github.event.review.state == 'approved' | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
show-progress: false | ||
fetch-depth: 0 | ||
- name: Prepare environment | ||
uses: ./.github/actions/prepare-environment | ||
- name: Get package name when dirty | ||
id: packages_name | ||
run: | | ||
## jq -c '[.[] | .name] | ||
## Получаем данные в формате ["@salutejs/plasma-new-hope","@salutejs/sdds-cs"] | ||
echo "PACKAGES_NAME=$(npx lerna la --json --since=$(git merge-base --fork-point origin/dev) --exclude-dependents | jq -c '[.[] | .name]')" >> "$GITHUB_OUTPUT" | ||
- name: Add label | ||
id: data | ||
uses: actions/github-script@v7 | ||
env: | ||
DATA: ${{ steps.packages_name.outputs.PACKAGES_NAME }} | ||
with: | ||
script: | | ||
const data = JSON.parse(process.env.DATA || []) ; | ||
if (!data.length) { | ||
console.log('Empty state'); | ||
return ''; | ||
} | ||
const labels = data | ||
.map((item) => item.replace('@salutejs/', '')) | ||
.map((item) => { | ||
if (item === 'plasma-new-hope') { | ||
return 'core'; | ||
} | ||
return item; | ||
}); | ||
github.rest.issues.addLabels({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
labels, | ||
}) |