Compare commits

..

4 Commits

Author SHA1 Message Date
Jef Roosens f6a3afb315
Fixed CI constraint 2022-04-02 15:41:51 +02:00
Jef Roosens 322f0430bf
Forgot to add matrix routes >:(
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/tag/woodpecker Pipeline was successful Details
2022-04-02 14:16:35 +02:00
Jef Roosens 799d0d4711
Hopefully fixed ci yaml
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/tag/woodpecker Pipeline failed Details
2022-04-02 13:52:48 +02:00
Jef Roosens a69f614129
Bumped release version 2022-04-02 13:50:47 +02:00
4 changed files with 22 additions and 7 deletions

View File

@ -1,5 +1,5 @@
platform: linux/amd64
branch: main
branches: main
pipeline:
release:
@ -12,7 +12,8 @@ pipeline:
secrets:
- 'docker_username'
- 'docker_password'
when: tag
when:
event: tag
deploy:
image: 'curlimages/curl'
@ -20,4 +21,5 @@ pipeline:
- 'webhook'
commands:
- curl -XPOST --fail -s "$WEBHOOK"
when: tag
when:
event: tag

3
Cargo.lock generated
View File

@ -634,12 +634,13 @@ dependencies = [
[[package]]
name = "site-backend"
version = "0.0.0"
version = "0.1.0"
dependencies = [
"axum",
"flate2",
"futures-util",
"hyper",
"serde_json",
"tar",
"tokio",
"tokio-util",

View File

@ -1,6 +1,6 @@
[package]
name = "site-backend"
version = "0.0.0"
version = "0.1.0"
edition = "2021"
publish = false
@ -22,3 +22,4 @@ flate2 = "1.0.22"
tokio-util = { version = "0.7.1", features = ["io"] }
futures-util = "0.3.21"
uuid = { version = "1.0.0-alpha.1", features = ["v4"] }
serde_json = "1.0.79"

View File

@ -1,12 +1,13 @@
use axum::{
extract::{BodyStream, Extension},
http::StatusCode,
response::IntoResponse,
routing::{get_service, post},
response::{IntoResponse, Json},
routing::{get, get_service, post},
Router,
};
use flate2::read::GzDecoder;
use futures_util::TryStreamExt;
use serde_json::{json, Value};
use std::collections::HashSet;
use std::io::ErrorKind;
use std::net::SocketAddr;
@ -37,6 +38,8 @@ async fn main() {
std::fs::create_dir_all(&static_dir);
let app = Router::new()
.route("/.well-known/matrix/server", get(get_matrix_server))
.route("/.well-known/matrix/client", get(get_matrix_client))
.route(
"/api/deploy",
post(post_deploy).layer(RequireAuthorizationLayer::bearer(&api_key)),
@ -61,6 +64,14 @@ async fn main() {
.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 {
// This converts a stream into something that implements AsyncRead, which we can then use to
// asynchronously write the file to disk