Merge pull request #48 from Cafegory/feature-47 #21
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: Test And Build And Deploy | |
on: | |
push: | |
branches: [ 'main' ] | |
jobs: | |
build_and_test: | |
runs-on: ubuntu-latest | |
permissions: | |
checks: write | |
contents: read | |
packages: write | |
pull-requests: write | |
issues: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | |
settings-path: ${{ github.workspace }} # location for the settings.xml file | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Import secret files | |
run: | | |
echo -e "${{ secrets.APPLICATION_COMMON}}" >> ./src/main/resources/application-common.yml | |
echo -e "${{ secrets.APPLICATION_PRODUCT}}" >> ./src/main/resources/application-product.yml | |
echo -e "${{ secrets.APPLICATION_LOCAL}}" >> ./src/main/resources/application-local.yml | |
echo -e "${{ secrets.APPLICATION_INFO_LOGGING}}" >> ./src/main/resources/application-info-logging.yml | |
echo -e "${{ secrets.APPLICATION_DEBUG_LOGGING}}" >> ./src/main/resources/application-debug-logging.yml | |
- name: Build with Gradle | |
continue-on-error: true | |
id: build_and_test | |
run: | |
./gradlew clean build --stacktrace | |
- name: Deploy file | |
uses: wlixcc/[email protected] | |
id: deploy_file | |
if: success() | |
with: | |
username: ${{ secrets.SSH_USERNAME }} | |
server: ${{ secrets.SSH_HOST }} | |
local_path: './build/libs/*' | |
remote_path: ${{ secrets.SSH_REMOTE_PATH }} | |
sftp_only: true | |
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Send Deploy Fail Message to Discord | |
continue-on-error: true | |
if: failure() | |
run: | | |
curl --location ${{secrets.DISCORD_WEBHOOK_URL}} \ | |
--header 'Content-Type: application/json' \ | |
--data '{ | |
"avatar_url": "https://cdn-icons-png.flaticon.com/512/25/25231.png", | |
"embeds": [ | |
{ | |
"title": "배포가 실패했습니다.", | |
"type": "rich", | |
"description": "배포가 실패했습니다.", | |
"url": "https://github.com/Cafegory/Cafegory_Backend_REST_API" | |
} | |
]}' | |
- name: Send Deploy Success Message to Discord | |
continue-on-error: true | |
if: success() | |
run: | | |
curl --location ${{secrets.DISCORD_WEBHOOK_URL}} \ | |
--header 'Content-Type: application/json' \ | |
--data '{ | |
"avatar_url": "https://cdn-icons-png.flaticon.com/512/25/25231.png", | |
"embeds": [ | |
{ | |
"title": "배포 성공!!", | |
"type": "rich", | |
"description": "배포가 성공했습니다!!! 아싸!!!", | |
"url": "${{ secrets.HTTP_API_SERVER_URL}}" | |
} | |
]}' | |
- name: 테스트 실패 시, 실패한 코드 라인에 Check 코멘트를 등록합니다 | |
uses: mikepenz/action-junit-report@v3 | |
if: always() | |
with: | |
report_paths: '**/build/test-results/test/TEST-*.xml' | |
token: ${{ secrets.GITHUB_TOKEN }} |