Skip to content

eesoymilk is pushing to Kamatera #68

eesoymilk is pushing to Kamatera

eesoymilk is pushing to Kamatera #68

Workflow file for this run

name: Build and deploy-to-kamatera-server
run-name: ${{ github.actor }} is pushing to Kamatera
on:
push:
paths:
- ".github/workflows/**.yml"
- "Dockerfile"
- "**.py"
- "requirements.txt"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
KAMATERA_USER: soymilk
KAMATERA_PORT: 22
GCPLOGS_AUTH_PATH: /root/.config/gcplogs/auth.json
GCP_PROJECT: eesoybot
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout GitHub Action
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ github.actor }}/soybot
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# - name: Copy docker-compose.yml to Kamatera
# run: |
# echo "${{ secrets.KAMATERA_KEY }}" > private_key.pem
# chmod 600 private_key.pem
# scp -o StrictHostKeyChecking=no \
# -i private_key.pem \
# -P ${{ env.KAMATERA_PORT }} \
# ./docker-compose.yml \
# ${{ env.KAMATERA_USER }}@${{ secrets.KAMATERA_HOST }}:${{ env.KAMATERA_PATH }}
deploy:
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: SSH to Kamatera and deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.KAMATERA_HOST }}
username: soymilk
key: ${{ secrets.KAMATERA_KEY }}
script: |
docker stop soybot || true
docker run -d \
--name soybot \
-e TOKEN=${{ secrets.TOKEN }} \
-e OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} \
-e GCP_PROJECT=${{ secrets.GCP_PROJECT }} \
--log-driver=gcplogs \
--log-opt gcp-project=${{ env.GCP_PROJECT }} \
ghcr.io/soymilk/soybot:latest