feat: Add CI/CD pipeline for release deployment and make server host/port configurable via environment variables.
Some checks failed
/ upload (release) Failing after 1m14s
Some checks failed
/ upload (release) Failing after 1m14s
This commit is contained in:
parent
24e6ac26f1
commit
b098214a9d
2 changed files with 31 additions and 3 deletions
25
.forgejo/workflows/pipeline.yaml
Normal file
25
.forgejo/workflows/pipeline.yaml
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
jobs:
|
||||||
|
upload:
|
||||||
|
runs-on: host
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- run: ~/.cargo/bin/cargo build -r
|
||||||
|
- run: |
|
||||||
|
curl -X POST \
|
||||||
|
-H "Authorization: token ${{ github.token }}" \
|
||||||
|
-F "attachment=@target/release/chat" \
|
||||||
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/${{ github.event.release.id }}/assets"
|
||||||
|
- run: |
|
||||||
|
export XDG_RUNTIME_DIR=/run/user/$(id -u)
|
||||||
|
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
|
||||||
|
cp target/release/chat ~/chat/chat
|
||||||
|
chmod +x ~/chat/chat
|
||||||
|
systemctl --user restart chat
|
||||||
|
|
@ -39,6 +39,8 @@ async fn main() {
|
||||||
// OAuth configuration
|
// OAuth configuration
|
||||||
let client_id = dotenvy::var("CLIENT_ID").unwrap();
|
let client_id = dotenvy::var("CLIENT_ID").unwrap();
|
||||||
let client_secret = dotenvy::var("CLIENT_SECRET").unwrap();
|
let client_secret = dotenvy::var("CLIENT_SECRET").unwrap();
|
||||||
|
let port = dotenvy::var("PORT").unwrap_or_else(|_| "3001".to_string());
|
||||||
|
let host = dotenvy::var("HOST").unwrap_or_else(|_| "http://localhost:".to_string() + &port);
|
||||||
// NOTE: In production, do not hardcode localhost
|
// NOTE: In production, do not hardcode localhost
|
||||||
let auth_url = AuthUrl::new("https://idm.flegr.me/application/o/authorize/".to_string())
|
let auth_url = AuthUrl::new("https://idm.flegr.me/application/o/authorize/".to_string())
|
||||||
.expect("Invalid authorization endpoint URL");
|
.expect("Invalid authorization endpoint URL");
|
||||||
|
|
@ -52,7 +54,7 @@ async fn main() {
|
||||||
Some(token_url),
|
Some(token_url),
|
||||||
)
|
)
|
||||||
.set_redirect_uri(
|
.set_redirect_uri(
|
||||||
RedirectUrl::new("http://localhost:3001/auth/callback".to_string())
|
RedirectUrl::new(host + "/auth/callback")
|
||||||
.expect("Invalid redirect URL"),
|
.expect("Invalid redirect URL"),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -79,8 +81,9 @@ async fn main() {
|
||||||
.with_state(app_state);
|
.with_state(app_state);
|
||||||
|
|
||||||
// Run the app
|
// Run the app
|
||||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:3001").await.unwrap();
|
let port = dotenvy::var("PORT").unwrap_or_else(|_| "3001".to_string());
|
||||||
println!("Chat server listening on http://0.0.0.0:3001");
|
let listener = tokio::net::TcpListener::bind("0.0.0.0:".to_string() + &port).await.unwrap();
|
||||||
|
println!("Chat server listening on http://0.0.0.0:{}", port);
|
||||||
axum::serve(listener, app).await.unwrap();
|
axum::serve(listener, app).await.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue