Merge pull request #53 from DevKor-github/feature/article #64
This file contains hidden or 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 - NestJS (Yarn) | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| - feature/ci | |
| pull_request: | |
| branches: | |
| - develop | |
| - feature/ci | |
| env: | |
| DOCKER_IMAGE: ghcr.io/liveforpresent/univent-api:latest | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22.16.0 | |
| cache: 'yarn' | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Lint | |
| run: yarn lint | |
| # 임시로 제외 | |
| #- name: Run Tests | |
| # run: yarn test | |
| - name: Build | |
| run: yarn build | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker build | |
| id: buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to ghcr | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ secrets.GHCR_USER }} | |
| password: ${{ secrets.GHCR_TOKEN }} | |
| - name: Build and Push | |
| id: docker_build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ env.DOCKER_IMAGE }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Login to ghcr | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ secrets.GHCR_USER }} | |
| password: ${{ secrets.GHCR_TOKEN }} | |
| - name: Deploy to EC2 | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| script: | | |
| cd /home/user/ezpz/TEAM-E-25-1-BE | |
| docker-compose pull | |
| docker-compose up -d --build | |
| docker system prune -f | |
| docker image prune -f | |
| docker volume prune -f | |
| docker container prune -f |