-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
65 additions
and
6 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Test Pull Request Workflow | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
pull_request_review: | ||
types: | ||
- submitted | ||
issue_comment: | ||
types: | ||
- created | ||
push: | ||
|
||
jobs: | ||
extract-pr-number: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set PR Number as Environment Variable | ||
run: echo "PR_NUMBER=${{ github.event.number }}" >> $GITHUB_ENV | ||
- name: Set User Handle as Environment Variable | ||
run: echo "USER_HANDLE=${{ github.actor }}" >> $GITHUB_ENV | ||
|
||
call-backend: | ||
needs: extract-pr-number | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Call Backend with PR Number and User Handle | ||
run: | | ||
PR_NUMBER="13" | ||
USER_HANDLE=${{ env.USER_HANDLE }} | ||
BACKEND_URL="https://f01c-89-212-199-23.ngrok-free.app/pr" | ||
curl -X POST -d "pr_number=$PR_NUMBER&user_handle=$USER_HANDLE" $BACKEND_URL |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,36 @@ | ||
use actix_web::{get, http::header::ContentType, post, web, HttpResponse}; | ||
use mongodb::Client; | ||
use std::sync::Mutex; | ||
use actix_web::{get, post, web, HttpResponse, Responder}; | ||
use serde::Deserialize; | ||
use fplus_lib::core::LDNApplication; | ||
|
||
|
||
#[derive(Deserialize)] | ||
pub struct PullRequestData { | ||
pr_number: String, | ||
user_handle: String, | ||
} | ||
|
||
#[get("/rkh")] | ||
pub async fn get() -> HttpResponse { | ||
HttpResponse::InternalServerError().finish() | ||
} | ||
|
||
#[post("/rkh")] | ||
pub async fn post() -> HttpResponse { | ||
HttpResponse::InternalServerError().finish() | ||
#[post("/pr")] | ||
pub async fn receive_pr(info: web::Json<PullRequestData>) -> impl Responder { | ||
let pr_number = info.pr_number.trim_matches('"').parse::<u64>(); | ||
|
||
match pr_number { | ||
Ok(pr_number) => { | ||
match LDNApplication::get_by_pr_number(pr_number).await { | ||
Ok(application_file) => { | ||
println!("Received PR data - PR Number: {}, User Handle: {}", pr_number, info.user_handle); | ||
HttpResponse::Ok().json(application_file) | ||
}, | ||
Err(error) => HttpResponse::InternalServerError().json(error.to_string()), | ||
} | ||
} | ||
Err(_) => HttpResponse::BadRequest().json("Invalid PR Number"), | ||
} | ||
} | ||
|
||
|
||
|