58 lines
1.6 KiB
YAML
58 lines
1.6 KiB
YAML
name: Server CI/CD
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
lint-and-build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: 코드 체크아웃
|
|
uses: actions/checkout@v4
|
|
|
|
- name: tolchain 의존성 클론
|
|
run: git clone --depth 1 https://github.com/tolelom/tolchain.git ../tolchain
|
|
|
|
- name: Go 설치
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.25'
|
|
|
|
- name: go vet 검증
|
|
run: go vet ./...
|
|
|
|
- name: 테스트 실행
|
|
run: go test ./... -count=1
|
|
|
|
- name: 빌드 검증
|
|
run: go build -o /dev/null .
|
|
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
needs: lint-and-build
|
|
steps:
|
|
- name: 서버에 배포
|
|
uses: appleboy/ssh-action@v1
|
|
with:
|
|
host: ${{ secrets.SERVER_HOST }}
|
|
username: ${{ secrets.SERVER_USER }}
|
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
port: 22
|
|
script: |
|
|
set -e
|
|
export PATH=$PATH:/usr/local/bin:/opt/homebrew/bin:$HOME/.docker/bin
|
|
cd /tmp
|
|
rm -rf a301-build
|
|
mkdir a301-build && cd a301-build
|
|
# Suppress token from logs
|
|
set +x
|
|
git clone --quiet https://tolelom:${{ secrets.GIT_TOKEN }}@git.tolelom.xyz/A301/a301_server.git a301_server 2>/dev/null
|
|
set -x
|
|
git clone --quiet https://github.com/tolelom/tolchain.git tolchain
|
|
docker build --no-cache -t a301-server:latest -f a301_server/Dockerfile .
|
|
cd ~/server
|
|
docker compose up -d --no-deps --force-recreate a301-server
|
|
rm -rf /tmp/a301-build
|