Skip to content

Cleanup

Cleanup #24

Workflow file for this run

name: CI
on:
push:
branches: ["main"]
jobs:
run-tests:
name: Run Tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "18" # Specify the Node.js version
- name: Install dependencies
run: yarn install
- name: Run tests
run: yarn run test
build-and-push-backend:
name: Build and Push Backend Docker Image
runs-on: ubuntu-latest
needs: run-tests
timeout-minutes: 15
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Registry
uses: docker/login-action@v1
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push Backend Docker image
uses: docker/build-push-action@v2
with:
context: .
file: apps/backend/Dockerfile
push: true
tags: dayrim/whale-backend:latest
build-and-push-web:
name: Build and Push Web Docker Image
runs-on: ubuntu-latest
needs: run-tests
timeout-minutes: 15
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Registry
uses: docker/login-action@v1
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push Web Docker image
uses: docker/build-push-action@v2
with:
context: .
file: apps/web/Dockerfile
push: true
tags: dayrim/whale-web:latest
deploy:
name: Deploy with Docker Compose
runs-on: ubuntu-latest
needs: [build-and-push-backend, build-and-push-web]
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Prepare .env file
run: |
echo "TELEGRAM_BOT_TOKEN=${{ secrets.TELEGRAM_BOT_TOKEN }}" >> .env
echo "TELEGRAM_WEBHOOK_DOMAIN=${{ secrets.TELEGRAM_WEBHOOK_DOMAIN }}" >> .env
echo "POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}" >> .env
echo "POSTGRES_USER=${{ secrets.POSTGRES_USER }}" >> .env
echo "POSTGRES_DB=${{ secrets.POSTGRES_DB }}" >> .env
echo "POSTGRES_HOST=${{ secrets.POSTGRES_HOST }}" >> .env
echo "POSTGRES_PORT=${{ secrets.POSTGRES_PORT }}" >> .env
echo "WEB_URL=${{ secrets.WEB_URL }}" >> .env
echo "TELEGRAM_APP_ID=${{ secrets.TELEGRAM_APP_ID }}" >> .env
echo "TELEGRAM_APP_ID_HASH=${{ secrets.TELEGRAM_APP_ID_HASH }}" >> .env
- name: Copy docker-compose file and .env file to remote server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.REMOTE_SERVER_IP }}
username: ${{ secrets.REMOTE_SERVER_USER }}
key: ${{ secrets.REMOTE_SSH_KEY }}
passphrase: ${{ secrets.REMOTE_SSH_PASSPHRASE }}
source: "./docker-compose.yml,./.env"
target: "~/whale-test"
- name: Deploy using Docker Compose
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_SERVER_IP }}
username: ${{ secrets.REMOTE_SERVER_USER }}
key: ${{ secrets.REMOTE_SSH_KEY }}
passphrase: ${{ secrets.REMOTE_SSH_PASSPHRASE }}
script: |
cd ~/whale-test
docker-compose pull
docker-compose up -d
docker-compose ps