[UNI-312] feat: preServing ์ ๊ฑฐ #150
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: FE CI / CD | |
on: | |
push: | |
branches: | |
- fe | |
- feat/UNI-312 | |
# paths: | |
# - "uniro_frontend/**" | |
jobs: | |
CI: | |
runs-on: ubuntu-latest | |
env: | |
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
IMAGE_NAME: uniro-fe | |
IMAGE_TAG: ${{ github.sha }} | |
steps: | |
- name: ์ฝ๋ ์ฒดํฌ์์ | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
driver: docker-container | |
- name: Create .env from secret | |
run: | | |
echo "${{ secrets.FE_ENV }}" > uniro_frontend/.env | |
- name: Google Cloud SDK ์ค์ | |
uses: "google-github-actions/auth@v2" | |
with: | |
credentials_json: ${{ secrets.GCP_SA_KEY }} | |
- name: Docker๋ฅผ ์ํ gcloud ์ธ์ฆ ์ค์ | |
run: gcloud auth configure-docker --quiet | |
- name: Docker ์ด๋ฏธ์ง ๋น๋ ๋ฐ ํธ์ | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: uniro_frontend/Dockerfile | |
push: true | |
tags: gcr.io/${{ env.GCP_PROJECT_ID }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
CD: | |
runs-on: ubuntu-latest | |
needs: CI | |
env: | |
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
IMAGE_NAME: uniro-fe | |
IMAGE_TAG: ${{ github.sha }} | |
DEPLOY_PATH: ${{ secrets.DEPLOY_SERVER_PATH }} | |
steps: | |
- name: ๋ฐฐํฌ ์๋ฒ์ SSH๋ก ์ฐ๊ฒฐํ์ฌ ๋ฐฐํฌ | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.DEPLOY_SERVER_HOST }} | |
username: ${{ secrets.DEPLOY_SERVER_USER }} | |
key: ${{ secrets.DEPLOY_SSH_KEY }} | |
envs: GCP_PROJECT_ID, IMAGE_NAME, IMAGE_TAG, DEPLOY_PATH, TEST | |
script: | | |
cd ${DEPLOY_PATH} | |
sudo docker rm -f ${IMAGE_NAME} || true | |
sudo docker login -u _json_key --password-stdin https://gcr.io <<< '${{ secrets.GCP_SA_KEY }}' | |
sudo docker pull gcr.io/${GCP_PROJECT_ID}/${IMAGE_NAME}:${IMAGE_TAG} | |
sudo docker run -d --name ${IMAGE_NAME} -p 3000:3000 gcr.io/${GCP_PROJECT_ID}/${IMAGE_NAME}:${IMAGE_TAG} | |
sudo docker network connect nginx_app-network ${IMAGE_NAME} | |
sudo docker exec nginx-container nginx -s reload |