Skip to content

Commit

Permalink
[COZY-431] fix: 환경변수 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
eple0329 committed Dec 4, 2024
1 parent a0edfb6 commit b44776a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/publish_cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ jobs:
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
docker build --build-arg SPRING_PROFILE=prod -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker build --build-arg SPRING_PROFILE=prod -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} .
- name: AWS ECR Push
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }} :${{ env.IMAGE_TAG }}
echo "::set-output name=image::${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}"
cd:
needs: ci
Expand All @@ -80,6 +80,7 @@ jobs:
AWS_REGION: ${{ secrets.PRODUCTION_AWS_REGION }}
ECR_REPOSITORY: ${{ secrets.PRODUCTION_ECR_REPOSITORY }}
ECR_URI: ${{ secrets.PRODUCTION_ECR_URI }}
PROFILE: ${{ secrets.PRODUCTION_PROFILE }}
SUBMODULE_TOKEN: ${{ secrets.SUBMODULE_ACTION_TOKEN }}
IMAGE_TAG: ${{ github.sha }}

Expand All @@ -91,17 +92,17 @@ jobs:
ENV_FILE: "/home/ubuntu/.env"
COMPOSE: "/home/ubuntu/docker-compose.yml"
with:
host: $EC2_HOST
host: ${{ env.EC2_HOST }}
username: ubuntu
key: $SSH_KEY
key: ${{ env.SSH_KEY }}
script: |
echo "ECR_URI=$ECR_URI" > /home/ubuntu/.env
echo "GITHUB_SHA=$IMAGE_TAG" >> /home/ubuntu/.env
echo "SPRING_PROFILES=dev" >> /home/ubuntu/.env
echo "ECR_URI=${{ env.ECR_URI }}" > /home/ubuntu/.env
echo "GITHUB_SHA=${{ env.IMAGE_TAG }}" >> /home/ubuntu/.env
echo "SPRING_PROFILES=${{ env.PROFILE }}" >> /home/ubuntu/.env
sudo docker stop $(sudo docker ps -a -q) || true
sudo docker rm $(sudo docker ps -a -q) || true
sudo docker images -q | xargs -r docker rmi || true
sudo docker system prune -af
aws ecr get-login-password --region ap-northeast-2 | sudo docker login --username AWS --password-stdin $ECR_URI && sudo docker pull $ECR_URI:$IMAGE_TAG
aws ecr get-login-password --region ap-northeast-2 | sudo docker login --username AWS --password-stdin ${{ env.ECR_URI }} && sudo docker pull ${{ env.ECR_URI }} :${{ env.IMAGE_TAG }}
sudo -E docker-compose up -d

0 comments on commit b44776a

Please sign in to comment.