Merge pull request #12 from MindsHub/develop #178
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
name: Rust | |
on: | |
push: | |
branches: [ "main" ] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
test: | |
# service containers to run with `build-test` | |
services: | |
# label used to access the service container | |
postgres: | |
# Docker Hub image | |
image: postgis/postgis:15-3.3 | |
# service environment variables | |
# `POSTGRES_HOST` is `postgres` | |
env: | |
# optional (defaults to `postgres`) | |
POSTGRES_DB: insignorocketdb | |
# required | |
POSTGRES_PASSWORD: test | |
# optional (defaults to `5432`) | |
POSTGRES_PORT: 5432 | |
# optional (defaults to `postgres`) | |
POSTGRES_USER: mindshub | |
ports: | |
# maps tcp port 5432 on service container to the host | |
- 5432:5432 | |
# set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- run: rustup toolchain install stable --profile minimal | |
#- name: Cache rust | |
# uses: Swatinem/[email protected] | |
# with: | |
# cache-all-crates: "true" | |
# prefix-key: "v0-rust" | |
# shared-key: "test" | |
# key: "test" | |
#cache-on-failure: "true" | |
#cache-directories: ".\n~.cargo" | |
# - name: Install deps | |
# run: sudo apt update | |
- uses: FedericoCarboni/setup-ffmpeg@v2 | |
id: setup-ffmpeg | |
- name: Install Diesel-cli | |
uses: baptiste0928/cargo-install@v2 | |
with: | |
crate: diesel_cli | |
#version: "^0.5" # | |
#- name: Install-diesel-Cli | |
# run: cargo install diesel_cli --no-default-features --features "postgres" | |
- name: Make migrations | |
run: diesel database reset --database-url="postgres://mindshub:test@localhost:5432/insignorocketdb" | |
- name: "CI testing" | |
run: cargo test -- --test-threads=1 | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- run: rustup toolchain install stable --profile minimal | |
# - name: Cache rust | |
# uses: Swatinem/[email protected] | |
# with: | |
# cache-all-crates: "true" | |
# prefix-key: "v0-rust" | |
# shared-key: "build" | |
# key: "build" | |
# cache-directories: "." | |
- name: Build | |
run: cargo build --release --bin insigno | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: build-result | |
path: target/release/insigno | |
document: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- run: rustup toolchain install nightly --profile minimal | |
- run: rustup override set nightly | |
# - name: Cache rust | |
# uses: Swatinem/[email protected] | |
# with: | |
# cache-all-crates: "true" | |
# prefix-key: "v0-rust-doc" | |
# shared-key: "test" | |
#à key: "test" | |
- name: BuildDoc | |
run: ./document | |
- name: parse | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
name: "documentation" | |
path: "docs" | |
deploy: | |
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment | |
permissions: | |
pages: write # to deploy to Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
contents: write | |
# Deploy to the github-pages environment | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-22.04 | |
needs: [build, test, document] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: build-result | |
path: target/release | |
- name: Deploy to GitHub Pages | |
uses: actions/deploy-pages@v2 | |
id: deployment | |
with: | |
artifact_name: "documentation" | |
- name: Kill Server | |
uses: appleboy/[email protected] | |
with: | |
host: ${{secrets.SSH_HOST}} | |
username: ${{secrets.SSH_USER}} | |
password: ${{secrets.SSH_PASS}} | |
port: ${{secrets.SSH_PORT}} | |
script: | | |
if pgrep insigno; then pkill insigno; fi | |
- name: Copy exec via SSH | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{secrets.SSH_HOST}} | |
username: ${{secrets.SSH_USER}} | |
password: ${{secrets.SSH_PASS}} | |
port: ${{secrets.SSH_PORT}} | |
source: "target/release/insigno" | |
target: "insigno" | |
strip_components: 2 | |
- name: Copy exec via SSH | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{secrets.SSH_HOST}} | |
username: ${{secrets.SSH_USER}} | |
password: ${{secrets.SSH_PASS}} | |
port: ${{secrets.SSH_PORT}} | |
source: "templates/*" | |
target: "insigno" | |
- name: Re-run server | |
uses: appleboy/[email protected] | |
with: | |
host: ${{secrets.SSH_HOST}} | |
username: ${{secrets.SSH_USER}} | |
password: ${{secrets.SSH_PASS}} | |
port: ${{secrets.SSH_PORT}} | |
script: | | |
cd insigno/ | |
chmod +x ./insigno | |
nohup ./insigno > nohup.out 2> nohup.err < /dev/null & |