fe-etc/CodeEditPageFix #90
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: PR Automation | |
on: | |
pull_request: | |
types: | |
- opened | |
- edited | |
branches-ignore: | |
- 'main' | |
jobs: | |
check_title: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check PR title format | |
run: | | |
pr_title=$(jq -r '.pull_request.title' "$GITHUB_EVENT_PATH") | |
title_pattern="(be|fe|ai)+-[A-Za-z]+\/[A-Za-z]+" | |
if [[ ! $pr_title =~ $title_pattern ]]; then | |
echo "error :: The PR title does not match the expected format." | |
echo "error :: Please follow this format: '파트명-기능명/기능타입'" | |
echo "error :: Example: 'be-api/test'" | |
exit 1 | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} | |
GITHUB_EVENT_PATH: ${{ github.event_path }} | |
auto_assign_reviewers: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Match reviewers based on PR author | |
run: | | |
PR_AUTHOR="${{ github.actor }}" | |
if [ "$PR_AUTHOR" == "humang" ]; then | |
REVIEWERS='["tank3a","CsLsj"]' | |
elif [ "$PR_AUTHOR" == "tank3a" ]; then | |
REVIEWERS='["seongho9","humang"]' | |
elif [ "$PR_AUTHOR" == "CsLsj" ]; then | |
REVIEWERS='["seongho9","humang"]' | |
elif [ "$PR_AUTHOR" == "seongho9" ]; then | |
REVIEWERS='["tank3a","CsLsj"]' | |
else | |
REVIEWERS=["tank3a","jackine08"] | |
fi | |
echo "REVIEWERS=$REVIEWERS" >> $GITHUB_ENV | |
- name: Use GitHub API to set reviewers | |
run: | | |
RESPONSE_CODE=$(curl \ | |
-o /dev/null \ | |
-s -w "%{http_code}" \ | |
-X POST \ | |
-H "Authorization: token ${{ secrets.WORKFLOW_TOKEN }}" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/UOS-CSDESIGN/Epimetheus/pulls/${{ github.event.pull_request.number }}/requested_reviewers \ | |
-d '{"reviewers":${{ env.REVIEWERS }}}') | |
if [ "$RESPONSE_CODE" -ne 201 ]; then | |
echo "Failed to set reviewers. Response code: $RESPONSE_CODE" | |
exit 1 | |
fi | |