Mafia-together ver 2.0 prod deploy (#165) #6
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: Prod CI/CD | |
on: | |
push: | |
branches: [ prod ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: dev | |
permissions: | |
pull-requests: write | |
steps: | |
- name: 레포지토리 체크아웃 | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 3 | |
token: ${{ secrets.SUBMODULE_TOKEN }} | |
submodules: true | |
- run: git log --pretty=oneline | |
- name: JDK 21을 설치합니다. | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '21' | |
distribution: 'corretto' | |
- name: gradlew 권한을 부여합니다. | |
run: chmod +x gradlew | |
- name: Gradle을 통해 빌드합니다. | |
run: ./gradlew build | |
- name: 빌드 파일 deploy 파일로 이동 | |
run: cp -f build/libs/*.jar /home/ubuntu/deploy/ | |
- name: Docker login | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push to DockerHub | |
run: | | |
cd /home/ubuntu/deploy | |
docker build --tag ${{secrets.DOCKER_USERNAME}}/${{secrets.DOCKER_USERNAME}} . | |
docker push ${{secrets.DOCKER_USERNAME}}/${{secrets.DOCKER_USERNAME}}:latest | |
- name: Deploy to prod server | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{secrets.PROD_SERVER}} | |
username: ${{secrets.PROD_USER_NAME}} | |
key: ${{secrets.PROD_PEM_KEY}} | |
script: | | |
cd ~/deploy | |
sh deploy.sh | |
- name: 성공 메시지 전송 | |
if: ${{ success() }} | |
uses: Ilshidur/[email protected] | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_GITHUB_WEBHOOK }} | |
DISCORD_USERNAME: Mafia-Together-BOT | |
DISCORD_AVATAR: https://i.namu.wiki/i/vMYV9DNseNCfKzaPIDshk7eG_7pAZm8BG6c2I_s6XXwyreDbpu3A1nDRUpbqvycQrRvgbSJeg15iXSSiGK5xyw.webp | |
DISCORD_EMBEDS: | | |
[ | |
{ | |
"author": { | |
"name": "${{ github.event.pull_request.user.login }}", | |
"url": "https://github.com/pknu-wap/WAPP/blob/main/image/icon.png?raw=true", | |
"icon_url": "${{ github.event.pull_request.user.avatar_url }}" | |
}, | |
"title": "배포 성공 ~ 파워 엉덩이 확인하자 ~ 🥰🥰 \n#${{ github.event.pull_request.number }} : ${{ github.event.pull_request.title }}", | |
"color": 10478271, | |
"description": "${{ github.event.pull_request.html_url }}", | |
"fields": [ | |
{ | |
"name": "Base Branch", | |
"value": "${{ github.base_ref }}", | |
"inline": true | |
}, | |
{ | |
"name": "Compare Branch", | |
"value": "${{ github.head_ref }}", | |
"inline": true | |
} | |
] | |
} | |
] | |
- name: 실패 메시지 전송 | |
if: ${{ failure() }} | |
uses: Ilshidur/[email protected] | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_GITHUB_WEBHOOK }} | |
DISCORD_USERNAME: Mafia-Together-BOT | |
DISCORD_AVATAR: https://i.namu.wiki/i/vMYV9DNseNCfKzaPIDshk7eG_7pAZm8BG6c2I_s6XXwyreDbpu3A1nDRUpbqvycQrRvgbSJeg15iXSSiGK5xyw.webp | |
DISCORD_EMBEDS: | | |
[ | |
{ | |
"author": { | |
"name": "${{ github.event.pull_request.user.login }}", | |
"url": "https://github.com/pknu-wap/WAPP/blob/main/image/icon.png?raw=true", | |
"icon_url": "${{ github.event.pull_request.user.avatar_url }}" | |
}, | |
"title": "배포 실패... 달리 엉덩이 가져와 \n#${{ github.event.pull_request.number }} : ${{ github.event.pull_request.title }}", | |
"color": 13458524, | |
"description": "${{ github.event.pull_request.html_url }}", | |
"fields": [ | |
{ | |
"name": "Base Branch", | |
"value": "${{ github.base_ref }}", | |
"inline": true | |
}, | |
{ | |
"name": "Compare Branch", | |
"value": "${{ github.head_ref }}", | |
"inline": true | |
} | |
] | |
} | |
] | |