Skip to content

Commit

Permalink
Merge pull request #274 from JupiterBroadcasting/infra/automated_depl…
Browse files Browse the repository at this point in the history
…oyment

Infra/automated deployment
  • Loading branch information
ironicbadger authored Aug 13, 2022
2 parents b716aa2 + f7d3832 commit bbcc88b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Deploy to VPS

on:
push:
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

# Build
- name: Pull latest changes on VPS
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VPS_HOST }}
USERNAME: ${{ secrets.VPS_DEPLOY_USER }}
PORT: ${{ secrets.VPS_SSH_PORT }}
KEY: ${{ secrets.VPS_SSHKEY }}
script: cd ${{ secrets.VPS_PROJECT_PATH }} && git fetch && git pull

- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VPS_HOST }}
USERNAME: ${{ secrets.VPS_DEPLOY_USER }}
PORT: ${{ secrets.VPS_SSH_PORT }}
KEY: ${{ secrets.VPS_SSHKEY }}
script: cd ${{ secrets.VPS_PROJECT_PATH }} && make deploy-prod
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
FROM registry.gitlab.com/pages/hugo/hugo_extended:0.101.0
CMD [ "serve", "-D", "--bind", "0.0.0.0" ]
ENTRYPOINT [ "hugo" ]
FROM registry.gitlab.com/pages/hugo/hugo_extended:0.101.0 as builder
WORKDIR /site
COPY . /site
RUN hugo

FROM nginx:alpine
RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /site/public /usr/share/nginx/html
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
dev:
docker build --rm -f Dockerfile -t jb_hugo:latest .
docker run --rm -it -v "$${PWD}":/app -w /app -p $${HOST_IP:-127.0.0.1}:1313:1313 jb_hugo:latest
docker run --rm -it -v "$${PWD}":/app -w /app -p $${HOST_IP:-127.0.0.1}:1313:1313 jb_hugo:latest

deploy-prod:
docker build -t jb-jbcom .
docker-compose -f ~/docker-compose.yml up -d jb-jbcom
docker image prune -af

0 comments on commit bbcc88b

Please sign in to comment.