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

access 토큰 없이 특정 리폼러의 data를 email 대신 nickname으로 가져오도록 수정 #175

Merged
Merged
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
107 changes: 53 additions & 54 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,69 +43,68 @@ jobs:

- name: Django 테스트 실행
env:
DJANGO_SETTINGS_MODULE: 'config.settings'
DJANGO_SETTINGS_MODULE: "config.settings"
DJANGO_DEBUG_MODE: true
UPCY_SECRET_KEY: 'test123123123123123123123' # 진짜 SECRET 키 아닙니다.
UPCY_SECRET_KEY: "test123123123123123123123" # 진짜 SECRET 키 아닙니다.
run: |
poetry run python manage.py migrate # 데이터베이스 마이그레이션
poetry run python manage.py test # Django 전체 테스트 실행


deploy:
name: Deploy Docker image to ECR and Run docker image in EC2 instance
# PR이 머지되었을 때만 실행
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:
- name: 코드 Checkout
uses: actions/checkout@v4

- name: AWS Credentials 가져오기
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{secrets.AWS_REGION}}

- name: AWS ECR 로그인
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: 백엔드 도커 이미지 생성 및 배포
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY_NAME }}
IMAGE_TAG: ${{ github.sha }}
run: |
# 도커 이미지 생성
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .

# ECR로 도커 이미지 PUSH
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest

- name: EC2에 배포 및 백엔드 어플리케이션 실행
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
script: ./deploy.sh

- name: 배포 결과 확인
if: always()
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
# 컨테이너 상태 확인
if docker ps | grep -q "${{ secrets.ECR_REPOSITORY_NAME }}"; then
echo "Container is running successfully"
exit 0
else
echo "Container is not running"
exit 1
fi
- name: 코드 Checkout
uses: actions/checkout@v4

- name: AWS Credentials 가져오기
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

- name: AWS ECR 로그인
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: 백엔드 도커 이미지 생성 및 배포
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY_NAME }}
IMAGE_TAG: ${{ github.sha }}
run: |
# 도커 이미지 생성
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .

# ECR로 도커 이미지 PUSH
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest

- name: EC2에 배포 및 백엔드 어플리케이션 실행
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
script: ./deploy.sh

- name: 배포 결과 확인
if: always()
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
# 컨테이너 상태 확인
if docker ps | grep -q "${{ secrets.ECR_REPOSITORY_NAME }}"; then
echo "Container is running successfully"
exit 0
else
echo "Container is not running"
exit 1
fi
2 changes: 1 addition & 1 deletion users/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
path("/token/refresh", UserTokenRefreshView.as_view(), name="token_refresh"),
path("/reformer", ReformerProfileView.as_view(), name="reformer"),
path(
"/reformer/<str:email>",
"/reformer/<str:nickname>",
ReformerSpecificProfileView.as_view(),
name="specific_reformer",
),
Expand Down
4 changes: 2 additions & 2 deletions users/views/reformer_view/reformer_specific_profile_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class ReformerSpecificProfileView(APIView):
AllowAny,
]

def get(self, request, email: str) -> Response:
def get(self, request, nickname: str) -> Response:
try:
user = User.objects.get(email=email)
user = User.objects.get(nickname=nickname)
reformer_profile = Reformer.objects.get(user=user)
if not reformer_profile:
raise Reformer.DoesNotExist(
Expand Down
Loading