Skip to content

Fix: 테이블 명 env로 수정 및 기타 콘솔 제거 (#29) #27

Fix: 테이블 명 env로 수정 및 기타 콘솔 제거 (#29)

Fix: 테이블 명 env로 수정 및 기타 콘솔 제거 (#29) #27

name: dev-deploy
on:
push:
branches:
- develop
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
run: |
docker build -t meta-test .
docker tag meta-test:latest ${{ secrets.DOCKER_USERNAME }}/meta-test:latest
docker push ${{ secrets.DOCKER_USERNAME }}/meta-test:latest
- name: SSH and deploy to EC2
run: |
echo "$SSH_KEY" > key.pem
chmod 600 key.pem
ssh -i key.pem -o StrictHostKeyChecking=no ${USER}@${HOST} << 'EOF'
docker pull ${{ secrets.DOCKER_USERNAME }}/meta-test:latest
docker stop meta-test-container || true
docker rm meta-test-container || true
docker run -d --name meta-test-container \
-e NODE_ENV=production \
-e JWT_SECRET=${{ secrets.JWT_SECRET }} \
-e ACCESS_TOKEN_EXPIRATION=1h \
-e REFRESH_TOKEN_EXPIRATION=3y \
-e AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY }} \
-e AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \
-e REGION=ap-northeast-2 \
-e AWS_DYNAMODB_TABLE_NAME=Dev-Metacognition-Test \
-e AWS_DYNAMODB_EMAIL_VERIFICATION_TABLE_NAME=Dev-Metacognition-Email-Verification \
-e [email protected] \
-e KAKAO_CLIENT_ID=${{ secrets.KAKAO_CLIENT_ID }} \
-e KAKAO_CLIENT_SECRET=${{ secrets.KAKAO_CLIENT_SECRET }} \
-e KAKAO_CALLBACK_URL=https://www.meta-cognition.site/auth \
-e GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }} \
-e GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }} \
-e GOOGLE_CALLBACK_URL=https://www.meta-cognition.site/auth \
-e GOOGLE_API_KEY=${{ secrets.GOOGLE_API_KEY }} \
-p 8080:8080 \
${{ secrets.DOCKER_USERNAME }}/meta-test:latest
docker logs meta-test-container
EOF
env:
USER: ${{ secrets.EC2_USER }}
HOST: ${{ secrets.EC2_HOST }}
SSH_KEY: ${{ secrets.EC2_SSH_KEY }}