Skip to content

Commit

Permalink
feat: Added GH action to deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Kapobajza committed Sep 9, 2024
1 parent 48cc84d commit c2b4b91
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build and deploy to VPS

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image
run: |
chmod +x ./scripts/build.sh
./scripts/build.sh api
./scripts/build.sh web
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy to VPS
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USERNAME }}
password: ${{ secrets.VPS_PASSWORD }}
port: ${{ secrets.VPS_PORT }}
script: |
cd ~/${{ secrets.VPS_APP_NAME }}
./scripts/deploy.sh api
./scripts/deploy.sh web
6 changes: 6 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

SERVICE_NAME=$1

docker build -t ghcr.io/kapobajza/$SERVICE_NAME:prod --platform linux/amd64 -f ./apps/api/Dockerfile .
docker push ghcr.io/kapobajza/$SERVICE_NAME:prod

0 comments on commit c2b4b91

Please sign in to comment.