๐ BugFix(#79): auth ์ฟผ๋ฆฌ ํค ์์ , Ranking ์ปดํฌ๋ํธ์ createdAt ํ๋ ์ถ๊ฐ #127
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: CI/CD Docker | |
on: | |
push: | |
branches: [feature/#79/Section_Part] | |
env: | |
DOCKER_IMAGE: ghcr.io/${{ github.actor }}/react-auto-deploy | |
VERSION: ${{ github.sha }} | |
NAME: go_cicd | |
VITE_BASE_URL: ${{ secrets.VITE_BASE_URL }} | |
VITE_IMG_BASE_URL: ${{ secrets.VITE_IMG_BASE_URL }} | |
jobs: | |
# ๋น๋ Job | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
# GitHub Repository์์ Checkout | |
- uses: actions/checkout@v3 | |
# Docker Buildx ์ค์ | |
- name: Set up docker buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
# Docker ์บ์ ์ค์ | |
- name: Cache docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ env.VERSION }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
# GitHub Container Registry ๋ก๊ทธ์ธ | |
- name: Login to ghcr | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ github.actor == 'bluetree7878' && secrets.bluetree7878_GHCR_TOKEN || secrets.rhehfl_ghcr_token }} | |
# Docker Build ๋ฐ Push | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
builder: ${{ steps.buildx.outputs.name }} | |
push: true | |
tags: ${{ env.DOCKER_IMAGE }}:latest | |
build-args: | | |
VITE_BASE_URL=${{ secrets.VITE_BASE_URL }} | |
VITE_IMG_BASE_URL=${{ secrets.VITE_IMG_BASE_URL }} | |
# ๋ฐฐํฌ Job | |
deploy: | |
needs: build # build ํ์ ์คํ๋๋๋ก ์ค์ | |
name: Deploy | |
runs-on: [self-hosted, label-go] # AWS ./configure์์ ์ฌ์ฉํ label๋ช | |
steps: | |
# GitHub Container Registry ๋ก๊ทธ์ธ | |
- name: Login to ghcr | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ github.actor == 'bluetree7878' && secrets.bluetree7878_GHCR_TOKEN || secrets.rhehfl_ghcr_token }} | |
# `.env` ํ์ผ ์์ฑ | |
- name: Generate .env file | |
run: | | |
echo IMAGE_NAME=${{ env.DOCKER_IMAGE }} > /home/ubuntu/.env | |
# Docker Compose๋ก ์๋น์ค ๋ฐฐํฌ | |
- name: Docker run | |
run: | | |
if [ -n "$(docker images -f "dangling=true" -q)" ]; then | |
docker rmi $(docker images -f "dangling=true" -q) | |
fi | |
docker compose -f /home/ubuntu/docker-compose.yml down | |
docker compose -f /home/ubuntu/docker-compose.yml up -d --pull always |