3. Hetzner Ord Deploy #113
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a workflow that deploys a fresh vermilion instance | |
name: 3. Hetzner Ord Deploy | |
# Controls when the workflow will run | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
inputs: | |
hetzner_server: | |
description: 'Which server to deploy to? Hetzner_blue or Hetzner_green' | |
required: true | |
default: 'Hetzner_' | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
Ord-Deploy: | |
runs-on: ubuntu-latest | |
environment: '${{ github.event.inputs.hetzner_server }}' | |
steps: | |
- name: Configure SSH | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "$SSH_KEY" > ~/.ssh/staging.key | |
chmod 600 ~/.ssh/staging.key | |
cat >>~/.ssh/config <<END | |
Host staging | |
HostName $SSH_HOST | |
User $SSH_USER | |
IdentityFile ~/.ssh/staging.key | |
StrictHostKeyChecking no | |
END | |
env: | |
SSH_USER: ${{ vars.SERVER_USER }} | |
SSH_KEY: ${{ secrets.SERVER_SSH_KEY }} | |
SSH_HOST: ${{ vars.SERVER_HOST }} | |
- name: Check out the new code from Github | |
run: ssh staging 'git -C Vermilion fetch && git -C Vermilion reset --hard origin/main || git clone git@github.com:SmarakNayak/Vermilion.git' # This pulls if directory exists, otherwise clones | |
- name: Get ord dependencies | |
run: | | |
ssh staging 'git -C ord fetch && git -C ord pull origin vermilion || git clone git@github-ord:SmarakNayak/ord.git && git -C ord switch vermilion' #ord code | |
ssh staging 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y' #rust | |
#- name: Get off chain collection data | |
# run: ssh staging 'aws s3 sync s3://ordinal-collections ordinal-collections' | |
- name: Install ord | |
run: ssh staging 'source /home/ubuntu/.cargo/env; cd ord; cargo build --release' #install | |
- name: Set up systemd services | |
run: ssh staging 'sudo cp Vermilion/systemd/ordserver.service /etc/systemd/system/ordserver.service; sudo systemctl daemon-reload;' | |
- name: Restart ord service | |
run: ssh staging 'sudo systemctl is-active ordserver.service && sudo systemctl restart ordserver.service || sudo systemctl start ordserver.service;' |