Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "fix/#111 CD 워크플로 실행 버그 픽스" #113

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions .github/workflows/dev-build-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
name: Build and Deploy to Dev Server

on:
push:
branches:
- develop
workflow_dispatch:

jobs:
build-docker-image:
runs-on: ubuntu-latest
environment: dev

steps:
- name: get repo from github
uses: actions/checkout@v3
Expand Down Expand Up @@ -38,27 +33,29 @@ jobs:

# Docker 이미지 빌드
- name: Docker image build
env:
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/aics-server:${{ github.sha }} .
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/aics-server:${{ github.sha }} ${{ secrets.DOCKERHUB_USERNAME }}/aics-server:latest
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:$IMAGE_TAG .
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:$IMAGE_TAG ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:latest
Comment on lines +36 to +40
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

쉘 스크립트 안전성 개선 및 이미지 이름 변경 확인 필요

Docker 빌드 명령어에서 변수 사용 시 따옴표 처리가 필요하며, 이미지 이름 변경이 전체 애플리케이션에서 일관되게 적용되었는지 확인이 필요합니다.

다음과 같이 수정을 제안드립니다:

- docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:$IMAGE_TAG .
- docker tag ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:$IMAGE_TAG ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:latest
+ docker build -t "${{ secrets.DOCKERHUB_USERNAME }}/aics-api:$IMAGE_TAG" .
+ docker tag "${{ secrets.DOCKERHUB_USERNAME }}/aics-api:$IMAGE_TAG" "${{ secrets.DOCKERHUB_USERNAME }}/aics-api:latest"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
env:
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/aics-server:${{ github.sha }} .
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/aics-server:${{ github.sha }} ${{ secrets.DOCKERHUB_USERNAME }}/aics-server:latest
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:$IMAGE_TAG .
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:$IMAGE_TAG ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:latest
env:
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t "${{ secrets.DOCKERHUB_USERNAME }}/aics-api:$IMAGE_TAG" .
docker tag "${{ secrets.DOCKERHUB_USERNAME }}/aics-api:$IMAGE_TAG" "${{ secrets.DOCKERHUB_USERNAME }}/aics-api:latest"
🧰 Tools
🪛 actionlint (1.7.4)

38-38: shellcheck reported issue in this script: SC2086:info:1:60: Double quote to prevent globbing and word splitting

(shellcheck)


38-38: shellcheck reported issue in this script: SC2086:info:2:55: Double quote to prevent globbing and word splitting

(shellcheck)


# Docker Hub 이미지 푸시
- name: docker Hub push
run: |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/aics-server:${{ github.sha }}
docker push ${{ secrets.DOCKERHUB_USERNAME }}/aics-server:latest
docker push ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:$IMAGE_TAG
docker push ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:latest
Comment on lines +45 to +46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Docker 푸시 명령어 안전성 개선 필요

변수를 포함한 Docker 푸시 명령어에도 따옴표 처리가 필요합니다.

다음과 같이 수정을 제안드립니다:

- docker push ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:$IMAGE_TAG
- docker push ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:latest
+ docker push "${{ secrets.DOCKERHUB_USERNAME }}/aics-api:$IMAGE_TAG"
+ docker push "${{ secrets.DOCKERHUB_USERNAME }}/aics-api:latest"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
docker push ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:$IMAGE_TAG
docker push ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:latest
docker push "${{ secrets.DOCKERHUB_USERNAME }}/aics-api:$IMAGE_TAG"
docker push "${{ secrets.DOCKERHUB_USERNAME }}/aics-api:latest"


deploy-to-dev:
runs-on: ubuntu-latest
needs: build-docker-image
steps:
- name: SSH to server and deploy
- name: Deploy to dev
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.SERVER_PORT }}
script: |
sudo -E docker-compose -f ${{ secrets.DOCKER_COMPOSE_YAML_PATH }} pull || exit 1
sudo -E docker-compose -f ${{ secrets.DOCKER_COMPOSE_YAML_PATH }} up -d || exit 1
sudo docker-compose pull ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:latest
sudo docker-compose up -d
2 changes: 1 addition & 1 deletion aics-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
spring:
application:
name: aics-server
name: aics-api

datasource:
url: jdbc:postgresql://${DB_HOST:localhost}:${DB_PORT:5432}/${DB_NAME:aics}
Expand Down