Skip to content

MySQL serverless adapter #65

MySQL serverless adapter

MySQL serverless adapter #65

Workflow file for this run

name: Deploy
on:
push:
branches: [main]
paths:
- "**/*.rs"
- "**/Cargo.toml"
- "Cargo.lock"
workflow_dispatch:
jobs:
# TODO: Remove all Go from this and cleanup
mattrax:
name: Build and deploy `mattrax` server
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: "true"
- name: Install Zig toolchain
uses: korandoru/setup-zig@v1
with:
zig-version: 0.11.0
- name:
Install 'cargo-zigbuild'
# The Rust cache action is not happy with `cargo bininstall` so we do a manual install.
run: |
curl -s https://api.github.com/repos/rust-cross/cargo-zigbuild/releases/latest \
| grep "browser_download_url.*.x86_64-unknown-linux-musl.tar.gz\"" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -qi -
tar -xf cargo-zigbuild-*.tar.gz
mv cargo-zigbuild /usr/local/bin
- name: Add 'aarch64-unknown-linux-gnu' target
run: rustup target add aarch64-unknown-linux-gnu
- name: Build Rust
run: cargo zigbuild --locked --release -p mattrax --target aarch64-unknown-linux-gnu
- name: Bundle all server files to push to server
run: |
mkdir server-dist
cp target/aarch64-unknown-linux-gnu/release/mattrax server-dist/mattrax
cp aws/mattrax.service server-dist/mattrax.service
# TODO: We should probs have concurrency 1 for these steps
- name: Copy files to production server
uses: appleboy/[email protected]
if: github.ref == 'refs/heads/main'
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
source: "server-dist/*"
target: /home/ec2-user
strip_components: 1
- name: executing remote ssh commands using password
uses: appleboy/[email protected]
if: github.ref == 'refs/heads/main'
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
sudo cp /home/ec2-user/mattrax.service /etc/systemd/system/mattrax.service
sudo systemctl daemon-reload
sudo systemctl enable mattrax
sudo systemctl restart mattrax