Compare commits
No commits in common. "f6a3afb3156d0049cb2653e134155b4fd75d286f" and "940dae97ca8cbb42e1d4838e647bbceb5859ea89" have entirely different histories.
f6a3afb315
...
940dae97ca
|
|
@ -1,5 +1,5 @@
|
||||||
platform: linux/amd64
|
platform: linux/amd64
|
||||||
branches: main
|
branch: main
|
||||||
|
|
||||||
pipeline:
|
pipeline:
|
||||||
release:
|
release:
|
||||||
|
|
@ -12,8 +12,7 @@ pipeline:
|
||||||
secrets:
|
secrets:
|
||||||
- 'docker_username'
|
- 'docker_username'
|
||||||
- 'docker_password'
|
- 'docker_password'
|
||||||
when:
|
when: tag
|
||||||
event: tag
|
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
image: 'curlimages/curl'
|
image: 'curlimages/curl'
|
||||||
|
|
@ -21,5 +20,4 @@ pipeline:
|
||||||
- 'webhook'
|
- 'webhook'
|
||||||
commands:
|
commands:
|
||||||
- curl -XPOST --fail -s "$WEBHOOK"
|
- curl -XPOST --fail -s "$WEBHOOK"
|
||||||
when:
|
when: tag
|
||||||
event: tag
|
|
||||||
|
|
|
||||||
|
|
@ -634,13 +634,12 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "site-backend"
|
name = "site-backend"
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"flate2",
|
"flate2",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"hyper",
|
"hyper",
|
||||||
"serde_json",
|
|
||||||
"tar",
|
"tar",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "site-backend"
|
name = "site-backend"
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
@ -22,4 +22,3 @@ flate2 = "1.0.22"
|
||||||
tokio-util = { version = "0.7.1", features = ["io"] }
|
tokio-util = { version = "0.7.1", features = ["io"] }
|
||||||
futures-util = "0.3.21"
|
futures-util = "0.3.21"
|
||||||
uuid = { version = "1.0.0-alpha.1", features = ["v4"] }
|
uuid = { version = "1.0.0-alpha.1", features = ["v4"] }
|
||||||
serde_json = "1.0.79"
|
|
||||||
|
|
|
||||||
15
src/main.rs
15
src/main.rs
|
|
@ -1,13 +1,12 @@
|
||||||
use axum::{
|
use axum::{
|
||||||
extract::{BodyStream, Extension},
|
extract::{BodyStream, Extension},
|
||||||
http::StatusCode,
|
http::StatusCode,
|
||||||
response::{IntoResponse, Json},
|
response::IntoResponse,
|
||||||
routing::{get, get_service, post},
|
routing::{get_service, post},
|
||||||
Router,
|
Router,
|
||||||
};
|
};
|
||||||
use flate2::read::GzDecoder;
|
use flate2::read::GzDecoder;
|
||||||
use futures_util::TryStreamExt;
|
use futures_util::TryStreamExt;
|
||||||
use serde_json::{json, Value};
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::io::ErrorKind;
|
use std::io::ErrorKind;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
@ -38,8 +37,6 @@ async fn main() {
|
||||||
std::fs::create_dir_all(&static_dir);
|
std::fs::create_dir_all(&static_dir);
|
||||||
|
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.route("/.well-known/matrix/server", get(get_matrix_server))
|
|
||||||
.route("/.well-known/matrix/client", get(get_matrix_client))
|
|
||||||
.route(
|
.route(
|
||||||
"/api/deploy",
|
"/api/deploy",
|
||||||
post(post_deploy).layer(RequireAuthorizationLayer::bearer(&api_key)),
|
post(post_deploy).layer(RequireAuthorizationLayer::bearer(&api_key)),
|
||||||
|
|
@ -64,14 +61,6 @@ async fn main() {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_matrix_server() -> impl IntoResponse {
|
|
||||||
Json(json!({"m.server": "matrix.rustybever.be:443"}))
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_matrix_client() -> impl IntoResponse {
|
|
||||||
Json(json!({"m.homeserver": {"base_url": "https://matrix.rustybever.be"}}))
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn post_deploy(Extension(data_dir): Extension<String>, res: BodyStream) -> impl IntoResponse {
|
async fn post_deploy(Extension(data_dir): Extension<String>, res: BodyStream) -> impl IntoResponse {
|
||||||
// This converts a stream into something that implements AsyncRead, which we can then use to
|
// This converts a stream into something that implements AsyncRead, which we can then use to
|
||||||
// asynchronously write the file to disk
|
// asynchronously write the file to disk
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue