Skip to content

Add deployment action #1

Add deployment action

Add deployment action #1

Workflow file for this run

name: Deploy
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
env:
NODE_ENV: production
GO_VERSION: "1.21.3"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Build Client
run: cd client && go build -o ./dist/client ./src
- name: Build API
run: cd ../api && bun run build
- name: Build Navigator
run: cd ../navigator && bun run build && cd ../
- name: Setup SSH
run: |
mkdir -p ~/.ssh/
echo "${{ secrets.PRIV_KEY }}" > ~/.ssh/id_rsa
echo "${{ secrets.PUB_KEY }}" > ~/.ssh/id_rsa.pub
chmod 600 ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa.pub
ssh-keyscan -H ${{ secrets.IP }} >> ~/.ssh/known_hosts
- name: Copy builds to server
run: |
ssh root@${{ secrets.IP }} "mkdir -p /root/freeflix"
rsync -vrm ./navigator/dist/* root@${{ secrets.IP }}:/root/freeflix/navigator --delete
scp ./docker-compose.yml root@${{ secrets.IP }}:/root/freeflix/docker-compose.yml
scp ./Caddyfile root@${{ secrets.IP }}:/root/freeflix/Caddyfile
scp ./api/dist/api.js root@${{ secrets.IP }}:/root/freeflix/api/api.js
scp ./client/dist/client root@${{ secrets.IP }}:/root/freeflix/client/client
ssh ${{ secrets.IP }} "cd /root/freeflix && docker-compose up -d --build"