diff --git a/.github/workflows/api-deploy-dev.yml b/.github/workflows/api-deploy-dev.yml index 5600813..a49ea0a 100644 --- a/.github/workflows/api-deploy-dev.yml +++ b/.github/workflows/api-deploy-dev.yml @@ -5,6 +5,7 @@ on: push: branches: [ develop ] paths: + - .github/workflows/** - plu-api/** - plu-common/** - plu-domain/** diff --git a/.github/workflows/api-deploy-prod.yml b/.github/workflows/api-deploy-prod.yml index 9b0d014..29e7cb2 100644 --- a/.github/workflows/api-deploy-prod.yml +++ b/.github/workflows/api-deploy-prod.yml @@ -5,6 +5,7 @@ on: push: branches: [ main ] paths: + - .github/workflows/** - plu-api/** - plu-common/** - plu-domain/** diff --git a/.github/workflows/api-pr-check-dev.yml b/.github/workflows/api-pr-check-dev.yml index 79e73d4..987cf02 100644 --- a/.github/workflows/api-pr-check-dev.yml +++ b/.github/workflows/api-pr-check-dev.yml @@ -7,6 +7,7 @@ on: pull_request: branches: [ develop ] paths: + - .github/workflows/** - plu-api/** - plu-common/** - plu-domain/** diff --git a/.github/workflows/api-pr-check-prod.yml b/.github/workflows/api-pr-check-prod.yml index 032dd7f..27178b0 100644 --- a/.github/workflows/api-pr-check-prod.yml +++ b/.github/workflows/api-pr-check-prod.yml @@ -7,6 +7,7 @@ on: pull_request: branches: [ main ] paths: + - .github/workflows/** - plu-api/** - plu-common/** - plu-domain/** diff --git a/.github/workflows/notification-deploy-dev.yml b/.github/workflows/notification-deploy-dev.yml index 980b019..5832aa8 100644 --- a/.github/workflows/notification-deploy-dev.yml +++ b/.github/workflows/notification-deploy-dev.yml @@ -7,6 +7,7 @@ on: push: branches: [ develop ] paths: + - .github/workflows/** - plu-notification/** - plu-common/** - plu-domain/** @@ -64,16 +65,16 @@ jobs: - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: - aws-access-key-id: ${{ secrets.AWS_S3_ACCESS_KEY_DEV }} - aws-secret-access-key: ${{ secrets.AWS_S3_SECRET_KEY_DEV }} - aws-region: ${{ secrets.AWS_REGION }} + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_DEV }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_DEV }} + aws-region: ap-northeast-2 - name: Upload to S3 run: aws s3 cp --region ap-northeast-2 ./notification-code-deploy.zip s3://$AWS_S3_BUCKET/notification-code-deploy.zip - name: Code Deploy run: aws deploy create-deployment - --application-name plu-codedeploy + --application-name plu-application --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name NOTIFICATION - --s3-location bucket=$AWS_S3_BUCKET_NAME,bundleType=zip,key=notification-code-deploy.zip \ No newline at end of file + --s3-location bucket=$AWS_S3_BUCKET,bundleType=zip,key=notification-code-deploy.zip \ No newline at end of file diff --git a/.github/workflows/notification-deploy-prod.yml b/.github/workflows/notification-deploy-prod.yml index 4e3e629..151cee4 100644 --- a/.github/workflows/notification-deploy-prod.yml +++ b/.github/workflows/notification-deploy-prod.yml @@ -5,7 +5,7 @@ name: notification-deploy-prod # Controls when the workflow will run on: push: - branches: [ develop ] + branches: [ main ] paths: - plu-notification/** - plu-common/** @@ -60,8 +60,8 @@ jobs: - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: - aws-access-key-id: ${{ secrets.AWS_S3_ACCESS_KEY_DEV }} - aws-secret-access-key: ${{ secrets.AWS_S3_SECRET_KEY_DEV }} + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_DEV }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_DEV }} aws-region: ap-northeast-2 - name: Upload to S3 @@ -69,7 +69,7 @@ jobs: - name: Code Deploy run: aws deploy create-deployment - --application-name plu-codedeploy + --application-name plu-application --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name NOTIFICATION - --s3-location bucket=$AWS_S3_BUCKET_NAME,bundleType=zip,key=notification-code-deploy.zip \ No newline at end of file + --s3-location bucket=$AWS_S3_BUCKET,bundleType=zip,key=notification-code-deploy.zip \ No newline at end of file diff --git a/.github/workflows/notification-pr-check-dev.yml b/.github/workflows/notification-pr-check-dev.yml index 6b6f837..652c502 100644 --- a/.github/workflows/notification-pr-check-dev.yml +++ b/.github/workflows/notification-pr-check-dev.yml @@ -5,6 +5,7 @@ on: pull_request: branches: [ develop ] paths: + - .github/workflows/** - plu-notification/** - plu-common/** - plu-domain/** diff --git a/.github/workflows/notification-pr-check-prod.yml b/.github/workflows/notification-pr-check-prod.yml index e43149b..4a047d4 100644 --- a/.github/workflows/notification-pr-check-prod.yml +++ b/.github/workflows/notification-pr-check-prod.yml @@ -7,6 +7,7 @@ on: pull_request: branches: [ main ] paths: + - .github/workflows/** - plu-notification/** - plu-common/** - plu-domain/** diff --git a/scripts/plu-api/health_check.sh b/scripts/plu-api/health_check.sh index c8a32d7..f71897d 100644 --- a/scripts/plu-api/health_check.sh +++ b/scripts/plu-api/health_check.sh @@ -6,22 +6,22 @@ if [ ${CURRENT_PORT} -eq 8081 ]; then elif [ ${CURRENT_PORT} -eq 8082 ]; then TARGET_PORT=8081 else - echo "No WAS is connected to nginx" + echo "No WAS is connected to nginx" >> /home/ubuntu/plu-api/deploy.log exit 1 fi -echo "Start health check of WAS at 'http://127.0.0.1:${TARGET_PORT}' ..." +echo "Start health check of WAS at 'http://127.0.0.1:${TARGET_PORT}' ..." >> /home/ubuntu/plu-api/deploy.log for RETRY_COUNT in 1 2 3 4 5 6 7 8 9 10 do - echo "#${RETRY_COUNT} trying..." - RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:${TARGET_PORT}/health) + echo "#${RETRY_COUNT} trying..." >> /home/ubuntu/plu-api/deploy.log + RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:${TARGET_PORT}/actuator/health) if [ ${RESPONSE_CODE} -eq 200 ]; then - echo "New WAS successfully running" + echo "New WAS successfully running" >> /home/ubuntu/plu-api/deploy.log exit 0 elif [ ${RETRY_COUNT} -eq 10 ]; then - echo "Health check failed." + echo "Health check failed." >> /home/ubuntu/plu-api/deploy.log exit 1 fi sleep 10 diff --git a/scripts/plu-api/run_new_was.sh b/scripts/plu-api/run_new_was.sh index de41d11..0f74edc 100644 --- a/scripts/plu-api/run_new_was.sh +++ b/scripts/plu-api/run_new_was.sh @@ -9,22 +9,22 @@ if [ ${CURRENT_PORT} -eq 8081 ]; then elif [ ${CURRENT_PORT} -eq 8082 ]; then TARGET_PORT=8081 else - echo "[$NOW_TIME] No WAS is connected to nginx" + echo "[$NOW_TIME] No WAS is connected to nginx" >> /home/ubuntu/plu-api/deploy.log fi TARGET_PID=$(lsof -Fp -i TCP:${TARGET_PORT} | grep -Po 'p[0-9]+' | grep -Po '[0-9]+') if [ ! -z ${TARGET_PID} ]; then - echo "Kill WAS running at ${TARGET_PORT}." + echo "Kill WAS running at ${TARGET_PORT}." >> /home/ubuntu/plu-api/deploy.log sudo kill ${TARGET_PID} fi if [ ${HOST_NAME} == "plu-prod-server" ]; then - nohup java -jar -Dserver.port=${TARGET_PORT} -Dspring.profiles.active=prod /home/ubuntu/plu-api/*.jar - echo "Now new WAS runs at ${TARGET_PORT}." + nohup java -jar -Dserver.port=${TARGET_PORT} -Dspring.profiles.active=prod /home/ubuntu/plu-api/*.jar >> /home/ubuntu/plu-api/deploy.log 2>/home/ubuntu/plu-api/deploy_err.log & + echo "Now new WAS runs at ${TARGET_PORT}." >> /home/ubuntu/plu-api/deploy.log exit 0 else - nohup java -jar -Dserver.port=${TARGET_PORT} -Dspring.profiles.active=dev /home/ubuntu/plu-api/*.jar - echo "Now new WAS runs at ${TARGET_PORT}." + nohup java -jar -Dserver.port=${TARGET_PORT} -Dspring.profiles.active=dev /home/ubuntu/plu-api/*.jar >> /home/ubuntu/plu-api/deploy.log 2>/home/ubuntu/plu-api/deploy_err.log & + echo "Now new WAS runs at ${TARGET_PORT}." >> /home/ubuntu/plu-api/deploy.log exit 0 fi \ No newline at end of file diff --git a/scripts/plu-api/switch.sh b/scripts/plu-api/switch.sh index c3bc5b7..a015995 100644 --- a/scripts/plu-api/switch.sh +++ b/scripts/plu-api/switch.sh @@ -3,20 +3,20 @@ NOW_TIME="$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S CURRENT_PORT=$(cat /etc/nginx/conf.d/service-url.inc | grep -Po '[0-9]+' | tail -1) TARGET_PORT=0 -echo "[$NOW_TIME] Nginx currently proxies to ${CURRENT_PORT}." +echo "[$NOW_TIME] Nginx currently proxies to ${CURRENT_PORT}." >> /home/ubuntu/plu-api/deploy.log if [ ${CURRENT_PORT} -eq 8081 ]; then TARGET_PORT=8082 elif [ ${CURRENT_PORT} -eq 8082 ]; then TARGET_PORT=8081 else - echo "[$NOW_TIME] No WAS is connected to nginx" + echo "[$NOW_TIME] No WAS is connected to nginx" >> /home/ubuntu/plu-api/deploy.log exit 1 fi echo "set \$service_url http://127.0.0.1:${TARGET_PORT};" | sudo tee /etc/nginx/conf.d/service-url.inc -echo "[$NOW_TIME] Now Nginx proxies to ${TARGET_PORT}." +echo "[$NOW_TIME] Now Nginx proxies to ${TARGET_PORT}." >> /home/ubuntu/plu-api/deploy.log sudo service nginx reload -echo "[$NOW_TIME] Nginx reloaded." \ No newline at end of file +echo "[$NOW_TIME] Nginx reloaded." >> /home/ubuntu/plu-api/deploy.log \ No newline at end of file diff --git a/scripts/plu-notification/deploy.sh b/scripts/plu-notification/deploy.sh index b1d56d6..06ef7d5 100644 --- a/scripts/plu-notification/deploy.sh +++ b/scripts/plu-notification/deploy.sh @@ -6,16 +6,16 @@ TARGET_PORT=8083 TARGET_PID=$(lsof -Fp -i TCP:${TARGET_PORT} | grep -Po 'p[0-9]+' | grep -Po '[0-9]+') if [ ! -z ${TARGET_PID} ]; then - echo "[$NOW_TIME] Kill WAS running at ${TARGET_PORT}." + echo "[$NOW_TIME] Kill WAS running at ${TARGET_PORT}." >> /home/ubuntu/plu-notification/deploy.log sudo kill ${TARGET_PID} fi if [ ${HOST_NAME} == "plu-prod-server" ]; then - nohup java -jar -Dserver.port=${TARGET_PORT} -Dspring.profiles.active=prod /home/ubuntu/plu-notification/*.jar - echo "[$NOW_TIME] Now new WAS runs at ${TARGET_PORT}." + nohup java -jar -Dserver.port=${TARGET_PORT} -Dspring.profiles.active=prod /home/ubuntu/plu-notification/*.jar >> /home/ubuntu/plu-notification/deploy.log 2>/home/ubuntu/plu-notification/deploy_err.log & + echo "[$NOW_TIME] Now new WAS runs at ${TARGET_PORT}." >> /home/ubuntu/plu-notification/deploy.log exit 0 else - nohup java -jar -Dserver.port=${TARGET_PORT} -Dspring.profiles.active=dev /home/ubuntu/plu-notification/*.jar - echo "[$NOW_TIME] Now new WAS runs at ${TARGET_PORT}." + nohup java -jar -Dserver.port=${TARGET_PORT} -Dspring.profiles.active=dev /home/ubuntu/plu-notification/*.jar >> /home/ubuntu/plu-notification/deploy.log 2>/home/ubuntu/plu-notification/deploy_err.log & + echo "[$NOW_TIME] Now new WAS runs at ${TARGET_PORT}." >> /home/ubuntu/plu-notification/deploy.log exit 0 fi \ No newline at end of file