chore(RSS-ECOMM-1_32): set up GitHub actions CI pipeline #19
Workflow file for this run
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: Continuous Integration | |
on: | |
pull_request: | |
branches: | |
- develop | |
jobs: | |
format: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Use Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '20' | |
- name: Install dependencies | |
run: npm install | |
- name: Format code with Prettier | |
run: npm run ci:format | |
automate-review: | |
permissions: | |
contents: read | |
pull-requests: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get PR Author | |
id: pr_author | |
run: echo "::set-output name=author::${{ github.event.pull_request.user.login }}" | |
- name: Select Reviewers | |
id: select_reviewers | |
run: | | |
author="${{ steps.pr_author.outputs.author }}" | |
all_users=("stardustmeg" "Kleostro" "YulikK") | |
# Exclude the PR author from the list of potential reviewers | |
potential_reviewers=() | |
for user in "${all_users[@]}"; do | |
if [[ "$user" != "$author" ]]; then | |
potential_reviewers+=("$user") | |
fi | |
done | |
# Select two reviewers from the potential reviewers list | |
selected_reviewers=("${potential_reviewers[@]:0:2}") | |
echo "::set-output name=reviewers::$(printf '%s' "${selected_reviewers[@]}")" | |
- name: Request Review | |
if: github.actor != steps.pr_author.outputs.author # Exclude the author | |
uses: octokit/[email protected] | |
with: | |
route: POST /repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers | |
mediaType: '{"previews":["luke-cage"]}' | |
token: ${{ secrets.GITHUB_TOKEN }} | |
reviewers: ${{ steps.select_reviewers.outputs.reviewers[0] }}, ${{ steps.select_reviewers.outputs.reviewers[1] }} |