Skip to content

feat: card api preview #83

feat: card api preview

feat: card api preview #83

name: Notification ready for review
on:
pull_request:
types: [ ready_for_review ]
branches:
- dev
jobs:
notification-review:
runs-on: ubuntu-latest
env:
TITLE: ${{ github.event.pull_request.title }}
URL: ${{ github.event.pull_request.html_url }}
AUTHOR: ${{ github.event.pull_request.user.login }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
- name: Install dependencies
run: |
cd .github/actions/get-reviewers
npm ci
- name: Computed reviewers state
id: reviewers
uses: ./.github/actions/get-reviewers
with:
token: ${{ secrets.GH_TOKEN }}
- name: Set reviewers
uses: actions/github-script@v7
env:
REVIEWERS_LIST: ${{ steps.reviewers.outputs.reviewers }}
with:
script: |
const fs = require('fs');
const path = '.github/teammates.json';
const teammates = JSON.parse(fs.readFileSync(path, 'utf8'));
const reviewers = JSON.parse(process.env.REVIEWERS_LIST);
// INFO: First, it is necessary to remove those who were automatically assigned from CODEOWNERS.
await github.rest.pulls.removeRequestedReviewers({
...context.repo,
pull_number: context.payload.pull_request.number,
reviewers: ['Yeti-or', ...Object.keys(teammates)],
});
// INFO: Set new list reviewers
await github.rest.pulls.requestReviewers({
...context.repo,
pull_number: context.payload.pull_request.number,
reviewers: reviewers.gh_list
});
- name: Send notification
uses: mattermost/action-mattermost-notify@master
with:
MATTERMOST_WEBHOOK_URL: ${{ secrets.WEBHOOKS_NOTIFICATIONS_MM }}
TEXT: |
👮🏻‍♂️ Вас ожидают на code review
**PR**: [${{ env.TITLE }}](${{ env.URL }})
**Reviewers**: ${{ fromJSON(steps.reviewers.outputs.reviewers).mm_list }}