Attempt to deploy as part of pipeline.

This commit is contained in:
Condorra 2023-02-12 23:05:34 +11:00
parent 88bfed0c7b
commit 0008c8b739
6 changed files with 46 additions and 10 deletions

View File

@ -3,18 +3,18 @@ set -Eeuo pipefail
export HOME=$(pwd) export HOME=$(pwd)
export CARGO_HOME=$(pwd)/.cargo export CARGO_HOME=$(pwd)/.cargo
echo Pre-build layout
ls -laR .
cd blastmud-repo cd blastmud-repo
BUILDSTAMP=$(date +%s)
echo Build timestamp for binary names: $BUILDSTAMP
echo Running tests echo Running tests
cargo test --target-dir ../target --profile release cargo test --target-dir ../target --profile release
echo Running main build echo Running main build
cargo build --target-dir ../target --profile release cargo build --target-dir ../target --profile release
echo Copying artifacts
cp ../target/release/blastmud_game ../output/
cp ../target/release/blastmud_listener ../output/
echo Final layout echo Copying artifacts
cd .. echo $BUILDSTAMP >../binaries/buildstamp
ls -laR . cp ../target/release/blastmud_game ../binaries/
cp ../target/release/blastmud_listener ../binaries/

14
.ci/deploy Normal file
View File

@ -0,0 +1,14 @@
#!/bin/bash
set -Eeuo pipefail
DEPLOY_HOST=172.19.11.5
echo $DEPLOY_KEY >deploy-key
chmod 0600 ./deploy-key
BUILDSTAMP=$(cat binaries/buildstamp)
tar -cvJf binary-archive-$BUILDSTAMP.tar.xz -C blastmud_game blastmud_listener
scp -i deploy-key binary-archive-$BUILDSTAMP.tar.xz blast@$DEPLOY_HOST:/home/blast/archive/
ssh -i deploy-key blast@$DEPLOY_HOST "find /home/blast/archive -mtime +30 -delete && mkdir -p /home/blast/latest && tar -xvJf /home/blast/archive/binary/binary-archive-$BUILDSTAMP.tar.xz -C /home/blast/latest"
# In the future, we should wrap this in a check it is needed...
ssh -i deploy-key blast@$DEPLOY_HOST "mv /home/blast/latest/blastmud_game /mnt/gameserver-app/exe"
ssh -i deploy-key blast@$DEPLOY_HOST "mv /home/blast/latest/blastmud_listener /mnt/listener-app/exe"

View File

@ -0,0 +1,2 @@
FROM debian:latest
RUN apt-get update && apt-get install -y jq ssh git curl ca-certificates xz-utils && rm -rf /var/lib/apt/lists/*

View File

@ -0,0 +1 @@
A base image for running our deploys. It is used by CI, but isn't auto-deployed by it.

View File

@ -0,0 +1,2 @@
docker build -t blasthavers/deploy-base:latest .
docker push blasthavers/deploy-base:latest

View File

@ -1,6 +1,9 @@
jobs: jobs:
- name: build-blastmud-image - name: build-blastmud-image
public: true public: true
build_log_retention:
days: 365
builds: 50
plan: plan:
- get: blastmud-repo - get: blastmud-repo
trigger: true trigger: true
@ -17,9 +20,23 @@ jobs:
- path: target - path: target
- path: .cargo - path: .cargo
outputs: outputs:
- name: output - name: binaries
run: run:
path: blastmud-repo/.ci/build path: blastmud-repo/.ci/build
- task: deploy
config:
platform: linux
image_resource:
type: registry-image
source:
repository: blasthavers/deploy-base
inputs:
- name: binaries
- name: blastmud-repo
params:
DEPLOY_KEY: ((deploy_key))
run:
path: blastmud-repo/.ci/deploy
resources: resources:
- name: blastmud-repo - name: blastmud-repo
type: git type: git