Skip to content

max height 80dvh (#50) #99

max height 80dvh (#50)

max height 80dvh (#50) #99

Workflow file for this run

name: cd
on:
push:
branches: [main]
jobs:
build_frontend:
name: Build frontend
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./frontend
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/restjson-frontend:${{ github.sha }}
build_api:
name: Build api
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push web api
uses: docker/build-push-action@v5
with:
context: ./api
file: ${{ github.workspace }}/api/Dockerfile
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/restjson-api:${{ github.sha }}
deploy_staging:
name: Deploy to staging server
needs: [build_frontend, build_api]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install SSH key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.DROPLET_SSH_KEY }}
- name: Copy over migration schemas
run: |
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -r ./api/sql/schema/. billy@${{ secrets.DROPLET_IP }}:/home/billy/restjson/sql/schema
- name: SSH and pull
run: |
ssh -o StrictHostKeyChecking=no billy@${{ secrets.DROPLET_IP }} << 'EOF'
cd /home/billy/restjson
docker run --rm --network host -v /home/billy/restjson/sql/schema:/migrations \
-e GOOSE_DRIVER="postgres" -e GOOSE_DBSTRING="postgres://postgres:postgres@localhost:5432/restjson?sslmode=disable" kukymbr/goose-docker:3.24.1
echo SHA=${{ github.sha }} > .env
docker compose pull
docker compose up -d
EOF