[bugfix/Inhabas#286] github actions 개선 및 버그 수정 #46
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: deploy-dev | |
on: | |
push: | |
branches: [ master ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: executing remote ssh commands using password | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.IBAS_DEV_HOST }} | |
username: ${{ secrets.IBAS_DEV_USERNAME }} | |
passphrase: ${{ secrets.IBAS_DEV_PASSWORD }} | |
key: ${{ secrets.IBAS_DEV_SSH_KEY }} | |
# port: ${{ secrets.PORT }} # default : 22 | |
script: | | |
set -e | |
REPO_PATH=${{ secrets.IBAS_DEV_PATH }}/Inhabas.com-api | |
if [ -d "$REPO_PATH" ]; then | |
cd $REPO_PATH | |
git checkout dev | |
git pull | |
else | |
echo "Error: Directory $REPO_PATH does not exist." | |
exit 1 | |
fi | |
chmod u+x gradlew | |
./gradlew build -x test | |
CONTAINER_NAME=api-dev | |
IMAGE_NAME=api-dev | |
if [ $(docker ps -q -f name=$CONTAINER_NAME) ]; then | |
docker stop $CONTAINER_NAME | |
docker rm $CONTAINER_NAME | |
fi | |
if [ $(docker images -q $IMAGE_NAME) ]; then | |
docker rmi $IMAGE_NAME | |
fi | |
docker build -t $IMAGE_NAME . | |
docker run -d --name $CONTAINER_NAME --network host -p 8082:8082 -e SPRING_CONFIG_IMPORT=configserver:http://localhost:8888 $IMAGE_NAME | |
echo "Deployment done" | |
- name: Notify Discord on Success | |
if: success() | |
run: | | |
curl -H "Content-Type: application/json" \ | |
-d '{"content": "Production deployment completed successfully!"}' \ | |
${{ secrets.DISCORD_WEBHOOK_URL }} | |
- name: Notify Discord on Failure | |
if: failure() | |
run: | | |
curl -H "Content-Type: application/json" \ | |
-d '{"content": "Production deployment failed!"}' \ | |
${{ secrets.DISCORD_WEBHOOK_URL }} |