Compare commits
7 commits
master
...
service-pr
Author | SHA1 | Date | |
---|---|---|---|
3819c93908 | |||
f6ab9102f4 | |||
02c3264b82 | |||
69b3ef7d59 | |||
7675a2c782 | |||
38ab0c3123 | |||
28a7420180 |
9 changed files with 299 additions and 497 deletions
12
.github/workflows/linux.yml
vendored
12
.github/workflows/linux.yml
vendored
|
@ -13,7 +13,6 @@ jobs:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
version:
|
version:
|
||||||
#- 1.51.0
|
|
||||||
- stable
|
- stable
|
||||||
# - nightly
|
# - nightly
|
||||||
|
|
||||||
|
@ -52,17 +51,22 @@ jobs:
|
||||||
- name: run tests
|
- name: run tests
|
||||||
run: make test
|
run: make test
|
||||||
|
|
||||||
- name: build and publish docker images
|
- name: build docker images
|
||||||
|
if: matrix.version == 'stable'
|
||||||
|
run: make docker
|
||||||
|
|
||||||
|
- name: publish docker images
|
||||||
|
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/pages'
|
||||||
run: make docker-publish
|
run: make docker-publish
|
||||||
|
|
||||||
- name: generate documentation
|
- name: generate documentation
|
||||||
if: matrix.version == 'stable' && (github.repository == 'realaravinth/pages')
|
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/pages'
|
||||||
run: make doc
|
run: make doc
|
||||||
env:
|
env:
|
||||||
GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
|
GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
|
||||||
|
|
||||||
- name: Deploy to GitHub Pages
|
- name: Deploy to GitHub Pages
|
||||||
if: matrix.version == 'stable' && (github.repository == 'realaravinth/pages')
|
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/pages'
|
||||||
uses: JamesIves/github-pages-deploy-action@3.7.1
|
uses: JamesIves/github-pages-deploy-action@3.7.1
|
||||||
with:
|
with:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
696
Cargo.lock
generated
696
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
29
Cargo.toml
29
Cargo.toml
|
@ -13,24 +13,17 @@ authors = ["realaravinth <realaravinth@batsense.net>"]
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "4.0.0-beta.9"
|
actix-web = "4.0.1"
|
||||||
actix-http = "3.0.0-beta.8"
|
actix-http = "3.0.4"
|
||||||
actix-rt = "2"
|
actix-rt = "2.6.0"
|
||||||
my-codegen = {package = "actix-web-codegen", git ="https://github.com/realaravinth/actix-web"}
|
|
||||||
|
|
||||||
config = "0.11"
|
config = "0.11"
|
||||||
git2 = "0.13.23"
|
|
||||||
|
|
||||||
serde = "1"
|
|
||||||
serde_json = "1"
|
|
||||||
|
|
||||||
pretty_env_logger = "0.4"
|
|
||||||
log = "0.4"
|
|
||||||
|
|
||||||
lazy_static = "1.4"
|
|
||||||
|
|
||||||
url = "2.2"
|
|
||||||
|
|
||||||
derive_more = "0.99"
|
derive_more = "0.99"
|
||||||
|
git2 = "0.14.2"
|
||||||
|
lazy_static = "1.4"
|
||||||
|
log = "0.4"
|
||||||
|
my-codegen = {package = "actix-web-codegen", git ="https://github.com/realaravinth/actix-web"}
|
||||||
num_cpus = "1.13"
|
num_cpus = "1.13"
|
||||||
|
pretty_env_logger = "0.4"
|
||||||
|
serde = { version = "1", features = ["derive"]}
|
||||||
|
serde_json = "1"
|
||||||
|
url = "2.2"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM rust:1.56-slim-bullseye as rust
|
FROM rust:slim as rust
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
RUN apt-get update && apt-get install -y git pkg-config libssl-dev
|
RUN apt-get update && apt-get install -y git pkg-config libssl-dev
|
||||||
RUN mkdir src && echo "fn main() {}" > src/main.rs
|
RUN mkdir src && echo "fn main() {}" > src/main.rs
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
**Auto-deploy static websites from git repositories**
|
**Auto-deploy static websites from git repositories**
|
||||||
|
|
||||||
|
`service-provider` branch contains changes and features that are more
|
||||||
|
suited for use by folks that host large number of websites like GitHub
|
||||||
|
Pages, etc.
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
[![Build](https://github.com/realaravinth/pages/actions/workflows/linux.yml/badge.svg)](https://github.com/realaravinth/pages/actions/workflows/linux.yml)
|
[![Build](https://github.com/realaravinth/pages/actions/workflows/linux.yml/badge.svg)](https://github.com/realaravinth/pages/actions/workflows/linux.yml)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
debug = true
|
log = "info" # possible values: "info", "warn", "trace", "error", "debug"
|
||||||
source_code = "https://github.com/realaravinth/pages"
|
source_code = "https://github.com/realaravinth/pages"
|
||||||
|
|
||||||
pages = [
|
pages = [
|
||||||
{ branch = "gh-pages", repo = "https://github.com/mCaptcha/website/", path ="/tmp/pages/mcaptcha/website", secret = "faee1b650ac586068a54cb160bd6353c5e16be7c64b49113fe57726e5393" },
|
{ branch = "gh-pages", repo = "https://github.com/mCaptcha/website/", path ="/tmp/pages/mcaptcha/website", secret = "faee1b650ac586068a54cb160bd6353c5e16be7c64b49113fe57726e5393" },
|
||||||
]
|
]
|
||||||
|
@ -13,6 +12,5 @@ port = 7000
|
||||||
ip= "0.0.0.0"
|
ip= "0.0.0.0"
|
||||||
# enter your hostname, eg: example.com
|
# enter your hostname, eg: example.com
|
||||||
domain = "localhost"
|
domain = "localhost"
|
||||||
allow_registration = true
|
|
||||||
proxy_has_tls = false
|
proxy_has_tls = false
|
||||||
#workers = 2
|
#workers = 2
|
||||||
|
|
|
@ -47,8 +47,7 @@ pub const PKG_HOMEPAGE: &str = env!("CARGO_PKG_HOMEPAGE");
|
||||||
#[cfg(not(tarpaulin_include))]
|
#[cfg(not(tarpaulin_include))]
|
||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
env::set_var("RUST_LOG", "info");
|
lazy_static::initialize(&SETTINGS);
|
||||||
|
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
|
@ -65,7 +64,7 @@ async fn main() -> std::io::Result<()> {
|
||||||
.app_data(get_json_err())
|
.app_data(get_json_err())
|
||||||
.wrap(
|
.wrap(
|
||||||
actix_middleware::DefaultHeaders::new()
|
actix_middleware::DefaultHeaders::new()
|
||||||
.header("Permissions-Policy", "interest-cohort=()"),
|
.add(("Permissions-Policy", "interest-cohort=()")),
|
||||||
)
|
)
|
||||||
.wrap(actix_middleware::NormalizePath::new(
|
.wrap(actix_middleware::NormalizePath::new(
|
||||||
actix_middleware::TrailingSlash::Trim,
|
actix_middleware::TrailingSlash::Trim,
|
||||||
|
|
18
src/page.rs
18
src/page.rs
|
@ -28,14 +28,22 @@ pub struct Page {
|
||||||
|
|
||||||
impl Page {
|
impl Page {
|
||||||
pub fn create_repo(&self) -> Repository {
|
pub fn create_repo(&self) -> Repository {
|
||||||
let repo = Repository::open(&self.path);
|
let repo = match Repository::open(&self.path) {
|
||||||
|
Ok(repo) => repo,
|
||||||
let repo = if repo.is_err() {
|
Err(e) => {
|
||||||
|
log::error!("Opening repo {} caused error {}", &self.path, e);
|
||||||
info!("Cloning repository {} at {}", self.repo, self.path);
|
info!("Cloning repository {} at {}", self.repo, self.path);
|
||||||
Repository::clone(&self.repo, &self.path).unwrap()
|
Repository::clone(&self.repo, &self.path).unwrap()
|
||||||
} else {
|
}
|
||||||
repo.unwrap()
|
|
||||||
};
|
};
|
||||||
|
//let repo = Repository::open(&self.path);
|
||||||
|
|
||||||
|
//let repo = if repo.is_err() {
|
||||||
|
// info!("Cloning repository {} at {}", self.repo, self.path);
|
||||||
|
// Repository::clone(&self.repo, &self.path).unwrap()
|
||||||
|
//} else {
|
||||||
|
// repo.unwrap()
|
||||||
|
//};
|
||||||
// let branch = repo.find_branch(&self.branch, BranchType::Local).unwrap();
|
// let branch = repo.find_branch(&self.branch, BranchType::Local).unwrap();
|
||||||
|
|
||||||
//repo.branches(BranchType::Local).unwrap().find(|b| b.unwrap().na
|
//repo.branches(BranchType::Local).unwrap().find(|b| b.unwrap().na
|
||||||
|
|
|
@ -18,6 +18,7 @@ use std::env;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use config::{Config, ConfigError, Environment, File};
|
use config::{Config, ConfigError, Environment, File};
|
||||||
|
use derive_more::Display;
|
||||||
use log::warn;
|
use log::warn;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
@ -40,9 +41,24 @@ impl Server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Display, Clone, Debug)]
|
||||||
|
#[serde(rename_all = "lowercase")]
|
||||||
|
pub enum LogLevel {
|
||||||
|
#[display(fmt = "debug")]
|
||||||
|
Debug,
|
||||||
|
#[display(fmt = "info")]
|
||||||
|
Info,
|
||||||
|
#[display(fmt = "trace")]
|
||||||
|
Trace,
|
||||||
|
#[display(fmt = "error")]
|
||||||
|
Error,
|
||||||
|
#[display(fmt = "warn")]
|
||||||
|
Warn,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
pub debug: bool,
|
pub log: LogLevel,
|
||||||
// pub database: Database,
|
// pub database: Database,
|
||||||
pub server: Server,
|
pub server: Server,
|
||||||
pub source_code: String,
|
pub source_code: String,
|
||||||
|
@ -108,6 +124,10 @@ impl Settings {
|
||||||
page.fetch_upstream(&page.branch);
|
page.fetch_upstream(&page.branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const LOG_VAR: &str = "RUST_LOG";
|
||||||
|
if env::var(LOG_VAR).is_err() {
|
||||||
|
env::set_var("RUST_LOG", format!("{}", settings.log));
|
||||||
|
}
|
||||||
Ok(settings)
|
Ok(settings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue