Skip to content

Deploy Index

Deploy Index #4

Workflow file for this run

name: Deploy Index
on:
release:
types: [published]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install needed tools
run: |
sudo apt-get update
sudo apt-get install -y bzip2
- name: Setup env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
tags: geode-index:${{ env.RELEASE_VERSION }}
push: false
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Push Docker image to index server
run: |
mkdir -p ~/.ssh
echo "${{ secrets.PRIVATE_KEY }}" > ~/.ssh/index_key
chmod 600 ~/.ssh/index_key
docker save geode-index:${{ github.ref }} | bzip2 | ssh -i ~/.ssh/index_key -o StrictHostKeyChecking=no ${{ secrets.INDEX_USER }}@${{ secrets.INDEX_SERVER }} docker load
- name: Replace current deployment
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.INDEX_USER }}@${{ secrets.INDEX_SERVER }} "docker stop index && docker rm index && cd ${{ secrets.INDEX_DIR }} && ./run.sh"