Skip to content

test: CI Deploy 테스트 #27

test: CI Deploy 테스트

test: CI Deploy 테스트 #27

Workflow file for this run

name: Test and Deploy
on:
push:
paths:
- 'src/**'
- 'package.json'
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'src/**'
- 'package.json'
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- name: Install packages
run: yarn install --frozen-lockfile
- name: Run tests
run: yarn test
build:
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/develop'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: ioloolo/wink-official-backend:latest
platforms: linux/amd64,linux/arm64
cache-from: type=registry,ref=ioloolo/wink-official-backend:buildcache
cache-to: type=registry,ref=ioloolo/wink-official-backend:buildcache,mode=max
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: SSH Action
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOSTNAME }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd ~/wink-official-backend
if [ ! -f "./deploy/config/backend.env" ]; then
echo "Error: backend config file(./deploy/config/backend.env) does not exist."
exit 1
fi
if [ "$(git rev-parse --abbrev-ref HEAD)" != "develop" ]; then
git checkout develop
fi
git pull origin develop
docker compose pull
docker compose down
docker compose up -d