Skip to content

fix: fixed websocket part in backend - needs frontend fix (#168) #5

fix: fixed websocket part in backend - needs frontend fix (#168)

fix: fixed websocket part in backend - needs frontend fix (#168) #5

Workflow file for this run

name: Deploy to Dev Server
on:
workflow_run:
workflows: ["compile-backend"]
branches: [dev]
types: [completed]
push:
branches: [dev]
# Required permissions to push to GHCR
permissions:
contents: read
packages: write
jobs:
be-compile:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Backend
run: |
# Lowercase the repo name to avoid Docker tag errors
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/webcorc-backend
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
docker build ./backend --tag $IMAGE_ID:latest --tag $IMAGE_ID:${{ github.sha }}
docker push $IMAGE_ID --all-tags
fe-compile:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Frontend
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/webcorc-frontend
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
docker build ./frontend --tag $IMAGE_ID:latest --tag $IMAGE_ID:${{ github.sha }}
docker push $IMAGE_ID --all-tags
deploy:
needs: ["be-compile", "fe-compile"]
runs-on: ubuntu-latest
steps:
- name: Execute remote SSH commands
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.DEV_HOST }}
username: ${{ secrets.DEV_USER }}
key: ${{ secrets.DEV_PRIVATE_KEY }}
script: |
cd /opt/WebCorC
# Pull latest changes to get the updated docker-compose.yml
git pull
REPO_OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
echo "${{ secrets.GITHUB_TOKEN }}" | sudo docker login ghcr.io -u ${{ github.actor }} --password-stdin
sudo docker pull ghcr.io/$REPO_OWNER/webcorc-backend:latest
sudo docker pull ghcr.io/$REPO_OWNER/webcorc-frontend:latest
sudo docker compose up -d --force-recreate
sudo docker image prune -f