Skip to content

revert https://github.com/andrew-s28/sourcedepth.com/pull/6 (#7) #7

revert https://github.com/andrew-s28/sourcedepth.com/pull/6 (#7)

revert https://github.com/andrew-s28/sourcedepth.com/pull/6 (#7) #7

name: Build Image 🏗️ and Deploy Frontend 💻 to VPS 🚀
# Builds the Docker image and deploys it to the VPS.
on:
workflow_dispatch:
push:
branches:
- main
paths:
- "frontend/**"
- "!frontend/mdx/**"
- "!frontend/static/**"
# Don't run full build on only public or mdx changes
# paths-ignore:
# - "!public/**"
# - "!mdx/**"
# - "!LICENSE"
# - "!README.md"
# - "!.gitignore"
# - "!.dockerignore"
# - "!.prettierignore"
release:
types: [published]
jobs:
build-versioned:
runs-on: ubuntu-latest
name: Built Versioned Image
if: github.event_name == 'release'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/sourcedepth.com
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./frontend
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/sourcedepth.com:${{ github.event.release.tag_name }}
${{ secrets.DOCKERHUB_USERNAME }}/sourcedepth.com:latest
annotations: ${{ steps.meta.outputs.annotations }}
build-latest:
runs-on: ubuntu-latest
name: Build Latest Image
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/sourcedepth.com
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./frontend
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/sourcedepth.com:latest
annotations: ${{ steps.meta.outputs.annotations }}
update-files:
name: Update Files on VPS
needs: build-latest
uses: ./.github/workflows/update-files.yaml
secrets: inherit
deploy:
runs-on: ubuntu-latest
name: Deploy to VPS
needs: update-files
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Build and restart Docker containers
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
script: |
cd ~/sourcedepth.com
docker compose down
docker compose up --pull always -d
docker system prune -f