Skip to content

Server Deployment

Server Deployment #119

Workflow file for this run

name: Server Deployment
on:
workflow_dispatch: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write # required for GHCR pushes
env:
REGISTRY: ghcr.io
IMAGE_NAME: ghcr.io/${{ github.repository }}
steps:
- name: 📥 Checkout
uses: actions/checkout@v4
- name: 🛡️ Setup SSH Key
run: |
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "${{ secrets.SSH_SECRET }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H "${{ secrets.SSH_HOST }}" >> ~/.ssh/known_hosts
- name: 🐳 Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 🔐 Login to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 🏗️ Build and push Container image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ env.IMAGE_NAME }}:server
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: 🏷️ Upload Compose File
run: |
scp ./scripts/server-compose.yml "${{ secrets.DEPLOY_SERVER }}:~/lncrawl/compose.yml"
- name: 🚀 Deploy over SSH
run: |
ssh "${{ secrets.DEPLOY_SERVER }}" << 'EOF'
mkdir -p ~/lncrawl/appdata
docker pull ${{ env.IMAGE_NAME }}:server
docker compose -f ~/lncrawl/compose.yml up -d
EOF