chore: 개발 서버 워크플로우 테스트 ( PR #118 ) #35
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: crews backend development version distribute | |
on: | |
push: | |
branches: [ "fix/workflow-slack-alarm" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.ACTION_TOKEN }} | |
submodules: true | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Cache Gradle dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
gradle-${{ runner.os }}- | |
- name: Set up MySQL | |
uses: mirromutth/[email protected] | |
with: | |
mysql database: 'crews' | |
mysql user: ${{ secrets.TEST_DB_USERNAME }} | |
mysql password: ${{ secrets.TEST_DB_PASSWORD }} | |
- name: Set up Redis And Redis Stack | |
uses: hoverkraft-tech/[email protected] | |
with: | |
compose-file: "./docker-compose-local.yml" | |
- name: Run Test And Create API Documentation | |
run: ./gradlew openapi3 | |
- name: Build with Gradle | |
run: ./gradlew bootJar -x test | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build Docker Image And Push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
tags: ${{ secrets.DOCKER_SERVER_IMAGE_NAME }} | |
platforms: | | |
linux/amd64 | |
linux/arm64 | |
alarm: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Extract PR number from commit message | |
id: pr_info | |
run: | | |
# Extract PR number from the commit message | |
PR_NUMBER=$(git log -1 --pretty=%B | grep -oP '#\d+' | sed 's/#//') | |
if [ -z "$PR_NUMBER" ]; then | |
echo "No PR number found in commit message" | |
exit 1 | |
fi | |
# Use GitHub API to get PR details | |
PR_URL="https://github.com/${{ github.repository }}/pull/$PR_NUMBER" | |
PR_TITLE=$(curl -s "https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER" | jq -r .title) | |
echo "PR_URL=$PR_URL" >> $GITHUB_ENV | |
echo "PR_TITLE=$PR_TITLE" >> $GITHUB_ENV | |
- name: Notify Slack on Success | |
if: success() | |
uses: slackapi/[email protected] | |
with: | |
payload: | | |
{ | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "새로운 개발 서버 버전이 배포됐어요! \n ✅ PR: <${{ env.PR_URL }}|${{ env.PR_TITLE }}>" | |
} | |
} | |
] | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_DEV }} | |
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK |