chore: Migrate project to monorepo structure (#91) #16
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: Server CI/CD | |
on: | |
push: | |
branches: [develop] | |
paths: | |
- 'server/**' | |
- 'core/**' | |
- '.github/workflows/server-ci-cd.yml' | |
jobs: | |
ci: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v3 | |
with: | |
version: '9' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Create .env file | |
working-directory: ./server | |
run: | | |
echo "REDIS_HOST=${{ secrets.REDIS_HOST }}" >> .env | |
echo "REDIS_PORT=${{ secrets.REDIS_PORT }}" >> .env | |
- name: Run tests | |
run: pnpm --filter server test | true | |
docker-deploy: | |
needs: ci | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Docker Setup | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and Push Docker Image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/troublepainter:latest | |
build-args: | | |
REDIS_HOST=${{ secrets.REDIS_HOST }} | |
REDIS_PORT=${{ secrets.REDIS_PORT }} | |
- name: Deploy to Server | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: mira | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
script: | | |
echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/troublepainter:latest | |
docker stop troublepainter || true | |
docker rm troublepainter || true | |
docker run -d --name troublepainter -p 3000:3000 -e REDIS_HOST=${{ secrets.REDIS_HOST }} -e REDIS_PORT=${{ secrets.REDIS_PORT }} --restart unless-stopped ${{ secrets.DOCKERHUB_USERNAME }}/troublepainter:latest |