actions/checkout, actions/setup-go, appleboy/ssh-action을 직접 실행 방식으로 대체. Gitea runner github.com clone 차단 문제 해결. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
58 lines
2.1 KiB
YAML
58 lines
2.1 KiB
YAML
name: Server CI/CD
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
lint-and-build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: 코드 체크아웃
|
|
run: |
|
|
git config --global --add safe.directory "$(pwd)"
|
|
git init
|
|
git remote add origin $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git
|
|
git fetch --depth=1 origin $GITHUB_SHA
|
|
git checkout $GITHUB_SHA
|
|
|
|
- name: tolchain 의존성 클론
|
|
run: git clone --depth 1 https://github.com/tolelom/tolchain.git ../tolchain
|
|
|
|
- name: Go 설치
|
|
run: |
|
|
curl -fsSL https://go.dev/dl/go1.25.5.linux-arm64.tar.gz -o /tmp/go.tar.gz
|
|
rm -rf /usr/local/go && tar -C /usr/local -xzf /tmp/go.tar.gz
|
|
export PATH=$PATH:/usr/local/go/bin
|
|
go version
|
|
|
|
- name: go vet 검증
|
|
run: |
|
|
export PATH=$PATH:/usr/local/go/bin
|
|
go vet ./...
|
|
|
|
- name: 테스트 실행
|
|
run: |
|
|
export PATH=$PATH:/usr/local/go/bin
|
|
go test ./... -count=1
|
|
|
|
- name: 빌드 검증
|
|
run: |
|
|
export PATH=$PATH:/usr/local/go/bin
|
|
go build -o /dev/null .
|
|
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
needs: lint-and-build
|
|
steps:
|
|
- name: 서버에 배포
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
|
|
chmod 600 ~/.ssh/deploy_key
|
|
ssh -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key \
|
|
${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} \
|
|
'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 && git clone --quiet https://tolelom:${{ secrets.GIT_TOKEN }}@git.tolelom.xyz/A301/a301_server.git a301_server && 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'
|
|
rm -f ~/.ssh/deploy_key
|