Skip to content

Commit

Permalink
fix: CD workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
MinhoJJang committed Aug 16, 2024
1 parent 06d0e14 commit 28a087c
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions .github/workflows/nextjs-prod-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,19 @@ jobs:
with:
ssh-private-key: ${{ secrets.SSH_KEY }}

- name: Add known hosts
- name: Add known hosts for Bastion Host
run: |
mkdir -p ~/.ssh
echo "BASTION_IP: ${{ secrets.BASTION_IP }}"
echo "WEB_IPS: ${{ secrets.WEB_IPS }}"
ssh-keyscan -H ${{ secrets.BASTION_IP }} >> ~/.ssh/known_hosts
if [ $? -ne 0 ]; then
echo "Failed to add BASTION_IP to known_hosts"
exit 1
fi
IFS=',' read -r -a HOSTS <<< "${{ secrets.WEB_IPS }}"
for host in "${HOSTS[@]}"; do
echo "Adding host $host to known_hosts"
ssh-keyscan -H $host >> ~/.ssh/known_hosts
if [ $? -ne 0 ]; then
echo "Failed to add $host to known_hosts"
exit 1
fi
done
- name: Deploy to FE
env:
BASTION_HOST: ${{ secrets.BASTION_IP }}
BASTION_HOST: ${{ secrets.BASTION_HOST }}
USER: ${{ secrets.USER }}
WEB_IPS: ${{ secrets.WEB_IPS }}
ACCESS_KEY: ${{ secrets.ACCESS_KEY }}
Expand All @@ -84,10 +74,10 @@ jobs:
echo "$ACCESS_SECRET_KEY" | docker login $KCR_REGISTRY --username $ACCESS_KEY --password-stdin
echo "Pulling new Docker image"
docker pull $KCR_REGISTRY/$KCR_REPOSITORY:${{ steps.get_version.outputs.version }}
docker pull $KCR_REGISTRY/$KCR_REPOSITORY:${{ steps.get_tag.outputs.tag }}
echo "Running new Docker container"
docker run -d -p 80:3000 --name frontend $KCR_REGISTRY/$KCR_REPOSITORY:${{ steps.get_version.outputs.version }}
docker run -d -p 80:3000 --name frontend $KCR_REGISTRY/$KCR_REPOSITORY:${{ steps.get_tag.outputs.tag }}
echo "Checking container health"
max_retries=5
Expand Down

0 comments on commit 28a087c

Please sign in to comment.