Update README.md #97
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: Deploy with Docker Compose | |
on: | |
push: | |
branches: ["main"] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Cache turbo build setup | |
uses: actions/cache@v4 | |
with: | |
path: .turbo | |
key: ${{ runner.os }}-turbo-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-turbo- | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Install pnpm | |
run: npm install -g pnpm | |
- name: install dependencies | |
run: pnpm install | |
- name: Generate Environment Variables File for Database | |
run: echo "DATABASE_URL=$DATABASE_URL" >> .env | |
working-directory: ./packages/database | |
env: | |
DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
- name: Generate Environment Variables File for Client | |
run: | | |
echo "SERVER_URL=$SERVER_URL" >> .env | |
echo "KAKAO_JAVASCRIPT_KEY=$KAKAO_JAVASCRIPT_KEY" >> .env | |
echo "FIREBASE_VAPID_KEY=$FIREBASE_VAPID_KEY" >> .env | |
echo "API_KEY=$API_KEY" >> .env | |
echo "AUTH_DOMAIN=$AUTH_DOMAIN" >> .env | |
echo "PROJECT_ID=$PROJECT_ID" >> .env | |
echo "STORAGE_BUCKET=$STORAGE_BUCKET" >> .env | |
echo "MESSAGING_SENDER_ID=$MESSAGING_SENDER_ID" >> .env | |
echo "APP_ID=$APP_ID" >> .env | |
echo "MEASUREMENT_ID=$MEASUREMENT_ID" >> .env | |
echo "PASSWORD_SALT=$PASSWORD_SALT" >> .env | |
working-directory: ./apps/client | |
env: | |
SERVER_URL: ${{ secrets.SERVER_URL }} | |
KAKAO_JAVASCRIPT_KEY: ${{ secrets.KAKAO_JAVASCRIPT_KEY }} | |
FIREBASE_VAPID_KEY: ${{ secrets.FIREBASE_VAPID_KEY }} | |
API_KEY: ${{ secrets.API_KEY }} | |
AUTH_DOMAIN: ${{ secrets.AUTH_DOMAIN }} | |
PROJECT_ID: ${{ secrets.PROJECT_ID }} | |
STORAGE_BUCKET: ${{ secrets.STORAGE_BUCKET }} | |
MESSAGING_SENDER_ID: ${{ secrets.MESSAGING_SENDER_ID }} | |
APP_ID: ${{ secrets.APP_ID }} | |
MEASUREMENT_ID: ${{ secrets.MEASUREMENT_ID }} | |
PASSWORD_SALT: ${{ secrets.PASSWORD_SALT }} | |
- name: Create JSON file | |
env: | |
TYPE: ${{ secrets.TYPE }} | |
PROJECT_ID: ${{ secrets.PROJECT_ID }} | |
PRIVATE_KEY_ID: ${{ secrets.PRIVATE_KEY_ID }} | |
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} | |
CLIENT_EMAIL: ${{ secrets.CLIENT_EMAIL }} | |
CLIENT_ID: ${{ secrets.CLIENT_ID }} | |
AUTH_URI: ${{ secrets.AUTH_URI }} | |
TOKEN_URI: ${{ secrets.TOKEN_URI }} | |
AUTH_PROVIDER_URL: ${{ secrets.AUTH_PROVIDER_URL }} | |
CLIENT_CERT_URL: ${{ secrets.CLIENT_CERT_URL }} | |
UNIVERSE_DOMAIN: ${{ secrets.UNIVERSE_DOMAIN }} | |
run: | | |
echo '{ | |
"type": "'"${TYPE}"'", | |
"project_id": "'"${PROJECT_ID}"'", | |
"private_key_id": "'"${PRIVATE_KEY_ID}"'", | |
"private_key": "'"${PRIVATE_KEY}"'", | |
"client_email": "'"${CLIENT_EMAIL}"'", | |
"client_id": "'"${CLIENT_ID}"'", | |
"auth_uri": "'"${AUTH_URI}"'", | |
"token_uri": "'"${TOKEN_URI}"'", | |
"auth_provider_x509_cert_url": "'"${AUTH_PROVIDER_URL}"'", | |
"client_x509_cert_url": "'"${CLIENT_CERT_URL}"'", | |
"universe_domain": "'"${UNIVERSE_DOMAIN}"'" | |
}' > ./apps/server/service-account.json | |
- name: build | |
run: pnpm turbo run build | |
- name: run unit tests | |
run: pnpm turbo run test | |
- name: run integration tests | |
run: pnpm turbo run test:integ | |
- name: download playwright browsers | |
run: pnpm exec playwright install | |
working-directory: ./apps/client | |
- name: run E2E test | |
run: pnpm turbo run test:e2e | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PW }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Cache Docker layers | |
uses: docker/bake-action@master | |
with: | |
push: true | |
load: true | |
files: |- | |
docker-compose.yml | |
docker-compose-cache.json | |
# - name: Build and push | |
# run: | | |
# docker compose build | |
# docker compose push | |
- name: Pull and restart Docker Container | |
uses: appleboy/ssh-action@master | |
with: | |
key: ${{ secrets.SSH_KEY }} | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USER }} | |
script: | | |
cd ./kkoo | |
docker compose down | |
docker compose pull | |
docker compose up -d | |
docker image prune -f | |
sudo systemctl restart nginx |