fix #101
Workflow file for this run
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: Build Docker Images | |
on: push | |
jobs: | |
run-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: npm ci && npx playwright install --with-deps | |
- name: Start backend | |
env: | |
DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
JWT_SECRET: ${{ secrets.JWT_SECRET }} | |
APP_URL: http://localhost:8080 | |
API_URL: http://localhost:3333 | |
LUNARY_PUBLIC_KEY: 259d2d94-9446-478a-ae04-484de705b522 | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
timeout-minutes: 1 | |
run: npm run start:backend & npx wait-on http://localhost:3333/v1/health | |
- name: Start frontend | |
env: | |
APP_URL: http://localhost:8080 | |
API_URL: http://localhost:3333 | |
NEXT_PUBLIC_API_URL: xyzPLACEHOLDERxyz | |
timeout-minutes: 2 | |
run: (npm run build:frontend && npm run start:frontend) & npx wait-on http://localhost:8080/ | |
- name: Run tests | |
run: npx playwright test | |
env: | |
BASE_URL: http://localhost:8080 | |
DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
build-and-push: | |
needs: run-tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the private Ops repo | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.ACCESS_TOKEN }} | |
submodules: "recursive" | |
- name: Generate data | |
id: date | |
run: echo "::set-output name=date::$(date +%Y-%m-%d-%Hh%Mm%Ss)" | |
- name: Get short commit hash | |
id: commit | |
run: echo "::set-output name=hash::$(git rev-parse --short HEAD)" | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to private Docker Registry | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }} | |
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} | |
- name: Build and push backend | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./ops/backend.Dockerfile | |
push: true | |
tags: | | |
lunary/backend:latest | |
lunary/backend:rev-${{ steps.date.outputs.date }}-${{ steps.commit.outputs.hash }} | |
platforms: linux/amd64 | |
- name: Build and push frontend | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./ops/frontend.Dockerfile | |
push: true | |
tags: | | |
lunary/frontend:latest | |
lunary/frontend:rev-${{ steps.date.outputs.date }}-${{ steps.commit.outputs.hash }} | |
platforms: linux/amd64 | |
- name: Build and push radar | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./ops/radar.Dockerfile | |
push: true | |
tags: | | |
lunary/radar:latest | |
lunary/radar:rev-${{ steps.date.outputs.date }}-${{ steps.commit.outputs.hash }} | |
platforms: linux/amd64 | |
- name: Build and push ml | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./ops/ml.Dockerfile | |
push: true | |
tags: | | |
lunary/ml:latest | |
lunary/ml:rev-${{ steps.date.outputs.date }}-${{ steps.commit.outputs.hash }} | |
platforms: linux/amd64 | |
deploy: | |
needs: build-and-push | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to Production | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.PRODUCTION_IP_ADDRESS }} | |
username: root | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
port: 3855 | |
script: | | |
cd /opt/lunary | |
docker compose pull | |
docker compose down | |
docker compose up -d |