프로필 이미지가 null일 경우 알림 전송에 실패하는 오류 해결 #330
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 코드 분석 | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize] | |
branches: [ main, develop, develop-be ] | |
permissions: write-all | |
jobs: | |
build: | |
if: contains(github.event.pull_request.labels.*.name, 'backend') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: settings java | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: cache gradle | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: chmod gradle | |
run: chmod +x backend/ddang/gradlew | |
- name: run jacocoTestCoverage | |
run: | | |
cd backend/ddang | |
./gradlew jacocoTestCoverage --info | |
- name: set author slack id | |
if: always() | |
id: author-slack | |
run: | | |
GIT_ID=${{ github.event.pull_request.user.login }} | |
if [ "$GIT_ID" == "apptie" ]; then | |
AUTHOR_NAME="${{ secrets.apptie_slack_display_name }}" | |
AUTHOR_ID="${{ secrets.apptie_slack_id }}" | |
elif [ "$GIT_ID" == "swonny" ]; then | |
AUTHOR_NAME="${{ secrets.swonny_slack_display_name }}" | |
AUTHOR_ID="${{ secrets.swonny_slack_id }}" | |
elif [ "$GIT_ID" == "JJ503" ]; then | |
AUTHOR_NAME="${{ secrets.JJ503_slack_display_name }}" | |
AUTHOR_ID="${{ secrets.JJ503_slack_id }}" | |
elif [ "$GIT_ID" == "kwonyj1022" ]; then | |
AUTHOR_NAME="${{ secrets.kwonyj1022_slack_display_name }}" | |
AUTHOR_ID="${{ secrets.kwonyj1022_slack_id }}" | |
fi | |
echo "AUTHOR_NAME=${AUTHOR_NAME}" >> $GITHUB_OUTPUT | |
echo "AUTHOR_ID=${AUTHOR_ID}" >> $GITHUB_OUTPUT | |
- name: set variables | |
id: variables | |
run: | | |
REVIEWERS_GIT_ID='${{ toJson(github.event.pull_request.requested_reviewers[*].login) }}' | |
reviewers=$(echo "$REVIEWERS_GIT_ID" | jq -r '.[]') | |
REVIEWERS_SLACK_ID="" | |
for reviewer in $reviewers; do | |
echo "Reviewer: $reviewer" | |
if [ "$reviewer" == "apptie" ]; then | |
REVIEWERS_SLACK_ID+="<@${{ secrets.apptie_slack_id }}> " | |
elif [ "$reviewer" == "swonny" ]; then | |
REVIEWERS_SLACK_ID+="<@${{ secrets.swonny_slack_id }}> " | |
elif [ "$reviewer" == "JJ503" ]; then | |
REVIEWERS_SLACK_ID+="<@${{ secrets.jj503_slack_id }}> " | |
elif [ "$reviewer" == "kwonyj1022" ]; then | |
REVIEWERS_SLACK_ID+="<@${{ secrets.kwonyj1022_slack_id }}> " | |
fi | |
done | |
echo "AUTHOR=${AUTHOR}" >> $GITHUB_OUTPUT | |
echo "REVIEWERS=${REVIEWERS}" >> $GITHUB_OUTPUT | |
echo "REVIEWERS_SLACK_ID=${REVIEWERS_SLACK_ID}" >> $GITHUB_OUTPUT | |
- name: slack success notification | |
run: | | |
SLACK_MESSAGE='{"text":"PR 브랜치 분석","blocks":[{"type":"section","text":{"type":"mrkdwn","text":">*PR 브랜치 분석* \n>\n>*PR Author*\n>' | |
SLACK_MESSAGE+="${{ steps.author-slack.outputs.AUTHOR_NAME }}" | |
SLACK_MESSAGE+="\n>\n>*PR 링크*\n><" | |
SLACK_MESSAGE+="${{ github.event.pull_request.html_url }} " | |
SLACK_MESSAGE+="> \n>\n>분석 결과\n>" | |
SLACK_MESSAGE+=":white_check_mark:" | |
SLACK_MESSAGE+="\n>\n>*리뷰어*\n>" | |
SLACK_MESSAGE+="${{ steps.variables.outputs.REVIEWERS_SLACK_ID }}" | |
SLACK_MESSAGE+='"}}]}' | |
curl -X POST ${{ secrets.SLACK_WEBHOOK }} -d "${SLACK_MESSAGE}" | |
- name: slack failed notification | |
if: failure() | |
run: | | |
SLACK_MESSAGE='{"text":"PR 브랜치 분석","blocks":[{"type":"section","text":{"type":"mrkdwn","text":">*PR 브랜치 분석* \n>\n>*PR Author*\n>' | |
SLACK_MESSAGE+="<@" | |
SLACK_MESSAGE+="${{ steps.author-slack.outputs.AUTHOR_ID }}" | |
SLACK_MESSAGE+=">" | |
SLACK_MESSAGE+="\n>\n>*PR 링크*\n><" | |
SLACK_MESSAGE+="${{ github.event.pull_request.html_url }} " | |
SLACK_MESSAGE+="> \n>\n>분석 결과\n>" | |
SLACK_MESSAGE+=":x:" | |
SLACK_MESSAGE+='"}}]}' | |
curl -X POST ${{ secrets.SLACK_WEBHOOK }} -d "${SLACK_MESSAGE}" | |
- name: slack cancelled notification | |
if: cancelled() | |
run: | | |
SLACK_MESSAGE='{"text":"PR 브랜치 분석","blocks":[{"type":"section","text":{"type":"mrkdwn","text":">*PR 브랜치 분석* \n>\n>*PR Author*\n>' | |
SLACK_MESSAGE+="<@" | |
SLACK_MESSAGE+="${{ steps.author-slack.outputs.AUTHOR_ID }}" | |
SLACK_MESSAGE+=">" | |
SLACK_MESSAGE+="\n>\n>*PR 링크*\n><" | |
SLACK_MESSAGE+="${{ github.event.pull_request.html_url }} " | |
SLACK_MESSAGE+="> \n>\n>분석 결과\n>" | |
SLACK_MESSAGE+=":black_square_for_stop:" | |
SLACK_MESSAGE+='"}}]}' | |
curl -X POST ${{ secrets.SLACK_WEBHOOK }} -d "${SLACK_MESSAGE}" |