From fed55590577d4c4563f79b3086bd3205968a535f Mon Sep 17 00:00:00 2001 From: Dominic Date: Wed, 31 Jul 2024 18:35:51 +0100 Subject: [PATCH 01/51] Update action.yml Signed-off-by: Dominic --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index cbbd82fb..a3b90d5a 100644 --- a/action.yml +++ b/action.yml @@ -19,10 +19,10 @@ inputs: required: true context: description: Directory in the repository where the Dockerfile or start command is located - default: "./" + required: false dockerfile: description: Path to the Dockerfile (optional) - required: false + default: "./Dockerfile" exposed_port: description: Port to expose in the container required: true From 084c6f6eff7a9d8d0d70bb8b5c40de25c836a3d8 Mon Sep 17 00:00:00 2001 From: Dominic Date: Wed, 31 Jul 2024 19:39:20 +0100 Subject: [PATCH 02/51] INTEGRATE PID FOR CLEANUP ADD PID MANAGEMENT Signed-off-by: Dominic --- pr-deploy.sh | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/pr-deploy.sh b/pr-deploy.sh index 30db7ea8..ef0f300c 100644 --- a/pr-deploy.sh +++ b/pr-deploy.sh @@ -12,12 +12,23 @@ PR_ACTION=$7 PR_NUMBER=$8 COMMENT_ID=$9 PR_ID="pr_${REPO_ID}${PR_NUMBER}" +# JSON file to store PIDs +PID_FILE="tunnel_pids.json" function handle_error { echo "{\"COMMENT_ID\": \"$COMMENT_ID\", \"DEPLOYED_URL\": \"\"}" exit 1 } +function kill_process_with_pid() { + # serveo + local key=$1 + ID=$(jq -r --arg key "$key" '.[$key]' "/srv/hngprojects/${PR_ID}/${PID_FILE}") + if [ -n $ID ]; then + kill -9 $ID + fi +} + # Set up trap to handle errors trap 'handle_error' ERR @@ -66,7 +77,7 @@ case $PR_ACTION in [ -n "$IMAGE_ID" ] && sudo docker rmi -f $IMAGE_ID # Exit early for 'closed' action - [ "$PR_ACTION" == "closed" ] && echo "{\"COMMENT_ID\": \"$COMMENT_ID\", \"DEPLOYED_URL\": \"\"}" && exit 0 + [ "$PR_ACTION" == "closed" ] && echo "{\"COMMENT_ID\": \"$COMMENT_ID\", \"DEPLOYED_URL\": \"\"}" && kill_process_with_pid "serveo" && exit 0 ;; esac @@ -83,28 +94,28 @@ sudo docker run -d -p $FREE_PORT:$EXPOSED_PORT --name $PR_ID $PR_ID echo "Start SSH session..." -# Checks if serveo +# Initialize the JSON file if it doesn't exist +if [ ! -f "$PID_FILE" ]; then + echo "{}" > "$PID_FILE" +fi + +# function to check if serveo was successful # check_serveo() { -# grep -q "ssh: connect to host serveo.net port 22: Connection refused" serveo_output.log || grep -q "ssh: connect to host serveo.net port 22: Connection timed out" serveo_output.log +# grep "Forwarding HTTP traffic from" serveo_output.log | tail -n 1 | awk '{print $5}' # } - # Set up tunneling using Serveo with a random high-numbered port nohup ssh -tt -o StrictHostKeyChecking=no -R 80:localhost:$FREE_PORT serveo.net > serveo_output.log 2>&1 & +SERVEO_PID=$! sleep 3 -# # Check if Serveo tunnel was set up successfully -# if [ check_serveo ]; then + +# Check if Serveo tunnel was set up successfully DEPLOYED_URL=$(grep "Forwarding HTTP traffic from" serveo_output.log | tail -n 1 | awk '{print $5}') -# else - # nohup ssh -tt -o StrictHostKeyChecking=no -R 80:localhost:$FREE_PORT ssh.localhost.run > localhost_run_output.log 2>&1 & - # sleep 30 - # # if grep -q "Connect to" localhost_run_output.log; then - # DEPLOYED_URL=$(grep "tunneled with tls termination" localhost_run_output.log | awk '{print $NF}') - # else - # DEPLOYED_URL="" - # fi -# fi + +if [ -n DEPLOYED_URL ]; then + jq --arg pid "$SERVEO_PID" '.serveo = $pid' "$PID_FILE" > tmp.$$.json && mv tmp.$$.json "$PID_FILE" +fi # Output the final JSON -echo "{\"COMMENT_ID\": \"$COMMENT_ID\", \"DEPLOYED_URL\": \"$DEPLOYED_URL\"}" +echo "{\"COMMENT_ID\": \"$COMMENT_ID\", \"DEPLOYED_URL\": \"$DEPLOYED_URL\", \"SERVEO_PID\": \"$SERVEO_PID\"}" From a93ce18252385474edb91e28bcc5187bc2af12ad Mon Sep 17 00:00:00 2001 From: Dominic Date: Wed, 31 Jul 2024 19:44:34 +0100 Subject: [PATCH 03/51] Update entrypoint.sh Signed-off-by: Dominic --- entrypoint.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index c33553dc..a6a21a5c 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -74,6 +74,9 @@ SANITIZED_OUTPUT=$(echo "$REMOTE_OUTPUT" | sed 's/[[:cntrl:]]//g') COMMENT_ID=$(echo "$SANITIZED_OUTPUT" | jq -r '.COMMENT_ID') DEPLOYED_URL=$(echo "$SANITIZED_OUTPUT" | jq -r '.DEPLOYED_URL') +# TO BE REMOVED LATER +echo "$SANITIZED_OUTPUT" | jq -r '.SERVEO_PID' + if [ -z "$DEPLOYED_URL" ]; then if [ "$PR_ACTION" == "closed" ]; then comment "Terminated 🛑" "#" && exit 0 From ab0fea1f29fa480f7c866ec78614086f2df21004 Mon Sep 17 00:00:00 2001 From: Destiny Date: Wed, 31 Jul 2024 19:53:14 +0100 Subject: [PATCH 04/51] feat: restore website --- Dockerfile | 10 ++ instance/database.db | Bin 0 -> 16384 bytes main.py | 6 ++ requirements.txt | 3 + website/__init__.py | 41 +++++++++ website/__pycache__/__init__.cpython-312.pyc | Bin 0 -> 2113 bytes website/__pycache__/auth.cpython-312.pyc | Bin 0 -> 4019 bytes website/__pycache__/models.cpython-312.pyc | Bin 0 -> 1779 bytes website/__pycache__/views.cpython-312.pyc | Bin 0 -> 2196 bytes website/auth.py | 66 ++++++++++++++ website/models.py | 18 ++++ website/static/index.js | 8 ++ website/templates/base.html | 91 +++++++++++++++++++ website/templates/home.html | 21 +++++ website/templates/login.html | 28 ++++++ website/templates/sign_up.html | 48 ++++++++++ website/views.py | 37 ++++++++ 17 files changed, 377 insertions(+) create mode 100644 Dockerfile create mode 100644 instance/database.db create mode 100644 main.py create mode 100644 requirements.txt create mode 100644 website/__init__.py create mode 100644 website/__pycache__/__init__.cpython-312.pyc create mode 100644 website/__pycache__/auth.cpython-312.pyc create mode 100644 website/__pycache__/models.cpython-312.pyc create mode 100644 website/__pycache__/views.cpython-312.pyc create mode 100644 website/auth.py create mode 100644 website/models.py create mode 100644 website/static/index.js create mode 100644 website/templates/base.html create mode 100644 website/templates/home.html create mode 100644 website/templates/login.html create mode 100644 website/templates/sign_up.html create mode 100644 website/views.py diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..f4287a3b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM python:3.8-slim-buster + +WORKDIR /python-docker + +COPY requirements.txt requirements.txt +RUN pip3 install -r requirements.txt + +COPY . . + +CMD [ "python3", "-m" , "flask", "--app", "main.py", "run", "--host=0.0.0.0", "--port=5000"] \ No newline at end of file diff --git a/instance/database.db b/instance/database.db new file mode 100644 index 0000000000000000000000000000000000000000..c5e92d481e52140eb42b24fa88d371f482ed3589 GIT binary patch literal 16384 zcmeI%K~KUk6bJAQh{_U#3*lt)Zf=QDiSfk6i3O)HqznzGWo9#30!-P6Uhxb1bv(Kb z2vO7zu>6~}OJBS0^|xM@4f>rR_US2{P28ByScNGHyC7nW<&s)R>bm^wE9-%Ot~qx6 za8oLOvi!co$_M3-S6Ie9zyR~Xnc^}2@}ZCrLZ$tY=RG4RN=Y~JRAte#EQu+uprwdlFAOZSFoUK>KIpC(0Lg?+k8RnK1eBoP4V+@pA$V4V*A)8Bc9MyS?w}rI8biopB zDJ?Nwv}8Mw4seJ^Sh(MEkycD89W>>uD6N_S7(=s4BKVlDCOA)e$1?j0{?t z9JXiSO)ML34(9MkDVr~j8bu?ENi}2|t}$sixZj-2wA`~vh7pc{8h>&KU6XGi7v`q8 z{!!5VmTe9WQ$q#ON3>^?KLszQ;8K4~?x3&v7hpw-b(Izn6+*t&o@-lsLV6@qhV;mD zG=-8GumW~qj^_|~?`VJFYcO%v_;ie&96A(3rZVb){6KI-CL{inxT*1i|a%REEbzcPaV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C`g5LSwnU z+{Dd%8@F)R`?I#UvLBtTE)7N}YouYUS;|2*Y9`k^rN3_FS$+eezM6BbEy8aXFAf6CY5ocoWMC)ZgH{!2A(FnH+|1mOUT9e|Gyz(>ac dpD@qJb*p~s7%=fT<`<^jeRK5{U>m2!e*pwDV-ElT literal 0 HcmV?d00001 diff --git a/website/__pycache__/views.cpython-312.pyc b/website/__pycache__/views.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5596c1bec8d9c95da2f7afef51d8888c85d44352 GIT binary patch literal 2196 zcmah~&2JM&6rWx1hm&2~B%q{i3P}V7ObZqjl^_I=D(DA?v=UURRuz`{H}m_w z{VkK}M$qPt{5XD7L+CFtkxg$4n-4&^fiS{~j{?O}0@YE2l#>cHM+qavbUlVoqJtv#F^$$7(a<7C8X+=aU*)MZP0 z5)<3sqT6j3IXXT65}$!+C5gt_B-ZJjG4i>mVx_#!yFT=**IbYn&hSzg%x*vCa?0WA5OTHqHu62!Q3uaDTK3PH6rw>BGy*8HWo4h zql(Xuas6wTOh?a^0#AK>>MYkj|Ln|Ju$cj2lOc}E?abl6>b-4JN=C0gk)>2qm}HcAf!HJ$z}Snq zumS0hyOT^344pxFdyI<2xK@FOrGi1Tz2c3B+-Qh};ZQUgQZ~$WLTO0hanogh(L_iE zVl-T0C2k6Q6kR-P#c?H!2_EKVR4tcD6wP)`h5B^GF=pjL;_Sp zL(fkazJLv*LJ5;7^xV>Pc)sL?g_B{q8UVDTLfH?ixG-6nIC!ui7%{bi(883psS<54V2DZy*zih*>}$zT+8(>)Ec#ixxu@+!6joQ zw`X2kx3cr>`jN$p*N&~(J$HI{|Jwh+KC<3Fu(WNt_RE!9S62H^%zv_GXBSR4PA`l# z#+rv$?OpBpLwoyOd;6+A2%(Gnf6m{x53O5oHIFWTwQ7yr(MC4m5NOseVB!--_KVbC zVx3@I%(`Wo zI>rt00H5M~j%%W>a@`M0IEv9u#UW!83Uqa}Zsit68YACN-0;8iSFD}&laDezi+daA z>L0DOObf>w$D6xXtl|2}-%aZgC`TKkH%EUu@xzIG*1nfu*u<;$&X+U*%yp}G@%`&Z z?`VDW9oRCzwe@G2q5^g?Ia}$+q!xK_E9O}-{@YLipcc)IAcRDs))lpH0)7HO>SD1{ z3P`a?1)jK0!zxrN!NWM)TPWT*zKiGSQCOwwljHOd*ah072)d1wq9{+$sr%^E6Ljb? zdgC$L@&~g1O!qAAX&zol@2cw?22#zd19JoOXPO@@?QRz811rkDM@sIQYAZ)KQ%Kz+ hx_37;m~QNl&gYiKm%bFP2cD^2O22R^#8P~ye*j^lx99)> literal 0 HcmV?d00001 diff --git a/website/auth.py b/website/auth.py new file mode 100644 index 00000000..8c65752e --- /dev/null +++ b/website/auth.py @@ -0,0 +1,66 @@ +from flask import Blueprint, render_template, request, flash, redirect, url_for +from .models import User +from werkzeug.security import generate_password_hash, check_password_hash +from . import db ##means from __init__.py import db +from flask_login import login_user, login_required, logout_user, current_user + + +auth = Blueprint('auth', __name__) + + +@auth.route('/login', methods=['GET', 'POST']) +def login(): + if request.method == 'POST': + email = request.form.get('email') + password = request.form.get('password') + + user = User.query.filter_by(email=email).first() + if user: + if check_password_hash(user.password, password): + flash('Logged in successfully!', category='success') + login_user(user, remember=True) + return redirect(url_for('views.home')) + else: + flash('Incorrect password, try again.', category='error') + else: + flash('Email does not exist.', category='error') + + return render_template("login.html", user=current_user) + + +@auth.route('/logout') +@login_required +def logout(): + logout_user() + return redirect(url_for('auth.login')) + + +@auth.route('/sign-up', methods=['GET', 'POST']) +def sign_up(): + if request.method == 'POST': + email = request.form.get('email') + first_name = request.form.get('firstName') + password1 = request.form.get('password1') + password2 = request.form.get('password2') + + user = User.query.filter_by(email=email).first() + if user: + flash('Email already exists.', category='error') + elif len(email) < 4: + flash('Email must be greater than 3 characters.', category='error') + elif len(first_name) < 2: + flash('First name must be greater than 1 character.', category='error') + elif password1 != password2: + flash('Passwords don\'t match.', category='error') + elif len(password1) < 7: + flash('Password must be at least 7 characters.', category='error') + else: + new_user = User(email=email, first_name=first_name, password=generate_password_hash( + password1, method='sha256')) + db.session.add(new_user) + db.session.commit() + login_user(new_user, remember=True) + flash('Account created!', category='success') + return redirect(url_for('views.home')) + + return render_template("sign_up.html", user=current_user) diff --git a/website/models.py b/website/models.py new file mode 100644 index 00000000..79c17e6f --- /dev/null +++ b/website/models.py @@ -0,0 +1,18 @@ +from . import db +from flask_login import UserMixin +from sqlalchemy.sql import func + + +class Note(db.Model): + id = db.Column(db.Integer, primary_key=True) + data = db.Column(db.String(10000)) + date = db.Column(db.DateTime(timezone=True), default=func.now()) + user_id = db.Column(db.Integer, db.ForeignKey('user.id')) + + +class User(db.Model, UserMixin): + id = db.Column(db.Integer, primary_key=True) + email = db.Column(db.String(150), unique=True) + password = db.Column(db.String(150)) + first_name = db.Column(db.String(150)) + notes = db.relationship('Note') diff --git a/website/static/index.js b/website/static/index.js new file mode 100644 index 00000000..136d2123 --- /dev/null +++ b/website/static/index.js @@ -0,0 +1,8 @@ +function deleteNote(noteId) { + fetch("/delete-note", { + method: "POST", + body: JSON.stringify({ noteId: noteId }), + }).then((_res) => { + window.location.href = "/"; + }); +} diff --git a/website/templates/base.html b/website/templates/base.html new file mode 100644 index 00000000..fbbd3854 --- /dev/null +++ b/website/templates/base.html @@ -0,0 +1,91 @@ + + + + + + + + + {% block title %}Home{% endblock %} + + + + + {% with messages = get_flashed_messages(with_categories=true) %} {% if + messages %} {% for category, message in messages %} {% if category == + 'error' %} + + {% else %} + + {% endif %} {% endfor %} {% endif %} {% endwith %} + +
{% block content %} {% endblock %}
+ + + + +{% block javascript %} + +{% endblock %} + + diff --git a/website/templates/home.html b/website/templates/home.html new file mode 100644 index 00000000..0fc5c1d9 --- /dev/null +++ b/website/templates/home.html @@ -0,0 +1,21 @@ +{% extends "base.html" %} {% block title %}Home{% endblock %} {% block content +%} +

Notes

+
    + {% for note in user.notes %} +
  • + {{ note.data }} + +
  • + {% endfor %} +
+
+ +
+
+ +
+
+{% endblock %} diff --git a/website/templates/login.html b/website/templates/login.html new file mode 100644 index 00000000..4f67e1b8 --- /dev/null +++ b/website/templates/login.html @@ -0,0 +1,28 @@ +{% extends "base.html" %} {% block title %}Login{% endblock %} {% block content +%} +
+

Login

+
+ + +
+
+ + +
+
+ +
+{% endblock %} diff --git a/website/templates/sign_up.html b/website/templates/sign_up.html new file mode 100644 index 00000000..0d401e10 --- /dev/null +++ b/website/templates/sign_up.html @@ -0,0 +1,48 @@ +{% extends "base.html" %} {% block title %}Sign Up{% endblock %} {% block +content %} +
+

Sign Up

+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+{% endblock %} diff --git a/website/views.py b/website/views.py new file mode 100644 index 00000000..d17a938e --- /dev/null +++ b/website/views.py @@ -0,0 +1,37 @@ +from flask import Blueprint, render_template, request, flash, jsonify +from flask_login import login_required, current_user +from .models import Note +from . import db +import json + +views = Blueprint('views', __name__) + + +@views.route('/', methods=['GET', 'POST']) +@login_required +def home(): + if request.method == 'POST': + note = request.form.get('note')#Gets the note from the HTML + + if len(note) < 1: + flash('Note is too short!', category='error') + else: + new_note = Note(data=note, user_id=current_user.id) #providing the schema for the note + db.session.add(new_note) #adding the note to the database + db.session.commit() + flash('Note added!', category='success') + + return render_template("home.html", user=current_user) + + +@views.route('/delete-note', methods=['POST']) +def delete_note(): + note = json.loads(request.data) # this function expects a JSON from the INDEX.js file + noteId = note['noteId'] + note = Note.query.get(noteId) + if note: + if note.user_id == current_user.id: + db.session.delete(note) + db.session.commit() + + return jsonify({}) From 490ba43ba6c35a0d3b1467cdc4f77c8e82444e0b Mon Sep 17 00:00:00 2001 From: Destiny Date: Wed, 31 Jul 2024 19:58:17 +0100 Subject: [PATCH 05/51] feat: rest9re deploy action --- .github/workflows/deploy.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..aabfd325 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,21 @@ +name: PR Deploy +on: + pull_request: + types: [opened, reopened, synchronize, closed] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Deploy PR + uses: ./ + with: + server_host: ${{ secrets.SERVER_HOST }} + server_username: ${{ secrets.SERVER_USERNAME }} + server_password: ${{ secrets.SERVER_PASSWORD }} + server_port: ${{ secrets.SERVER_PORT }} + context: '.' + dockerfile: 'Dockerfile' + exposed_port: '5000' + github_token: ${{ secrets.GITHUB_TOKEN }} From bcc969292f41851855d055796c080a61f1ac44c2 Mon Sep 17 00:00:00 2001 From: Dominic Date: Wed, 31 Jul 2024 20:59:09 +0100 Subject: [PATCH 06/51] Update pr-deploy.sh Signed-off-by: Dominic --- pr-deploy.sh | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/pr-deploy.sh b/pr-deploy.sh index ef0f300c..321cdbe1 100644 --- a/pr-deploy.sh +++ b/pr-deploy.sh @@ -13,17 +13,20 @@ PR_NUMBER=$8 COMMENT_ID=$9 PR_ID="pr_${REPO_ID}${PR_NUMBER}" # JSON file to store PIDs -PID_FILE="tunnel_pids.json" +PID_FILE="/srv/pr-deploy/nohup_pids.json" +COMMENT_ID_FILE="/srv/pr-deploy/comment_ids.json" +DEPLOY_FOLDER="/srv/pr-deploy" function handle_error { echo "{\"COMMENT_ID\": \"$COMMENT_ID\", \"DEPLOYED_URL\": \"\"}" exit 1 } +# This helps to kill the process created by nohup using the process id function kill_process_with_pid() { # serveo local key=$1 - ID=$(jq -r --arg key "$key" '.[$key]' "/srv/hngprojects/${PR_ID}/${PID_FILE}") + ID=$(jq -r --arg key "$key" '.[$key]' "${PID_FILE}") if [ -n $ID ]; then kill -9 $ID fi @@ -48,16 +51,17 @@ fi FREE_PORT=$(python3 -c 'import socket; s = socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()') # Setup directory -mkdir -p /srv/hngprojects/ -cd /srv/hngprojects +mkdir -p ${DEPLOY_FOLDER}/ +cd ${DEPLOY_FOLDER} rm -rf $PR_ID # Handle COMMENT_ID if [ -n "$COMMENT_ID" ]; then - echo "$COMMENT_ID" > "${PR_ID}.txt" + # echo "$COMMENT_ID" > "${PR_ID}.txt" + jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = $cid' "$COMMENT_ID_FILE" > tmp.$$.json && mv tmp.$$.json "$COMMENT_ID_FILE" else - if [ -f "${PR_ID}.txt" ]; then - COMMENT_ID=$(cat "${PR_ID}.txt") + if [ -f "$COMMENT_ID_FILE" ]; then + COMMENT_ID=$(jq -r --arg key "$PR_ID" '.[$key]' "$COMMENT_ID_FILE") else COMMENT_ID="" fi @@ -77,7 +81,7 @@ case $PR_ACTION in [ -n "$IMAGE_ID" ] && sudo docker rmi -f $IMAGE_ID # Exit early for 'closed' action - [ "$PR_ACTION" == "closed" ] && echo "{\"COMMENT_ID\": \"$COMMENT_ID\", \"DEPLOYED_URL\": \"\"}" && kill_process_with_pid "serveo" && exit 0 + [ "$PR_ACTION" == "closed" ] && echo "{\"COMMENT_ID\": \"$COMMENT_ID\", \"DEPLOYED_URL\": \"\"}" && kill_process_with_pid $PR_ID && exit 0 ;; esac @@ -94,11 +98,16 @@ sudo docker run -d -p $FREE_PORT:$EXPOSED_PORT --name $PR_ID $PR_ID echo "Start SSH session..." -# Initialize the JSON file if it doesn't exist +# Initialize the JSON file for nohup if it doesn't exist if [ ! -f "$PID_FILE" ]; then echo "{}" > "$PID_FILE" fi +# Initialize the JSON file for comment if it doesn't exist +if [ ! -f "$COMMENT_FILE" ]; then + echo "{}" > "$COMMENT_FILE" +fi + # function to check if serveo was successful # check_serveo() { # grep "Forwarding HTTP traffic from" serveo_output.log | tail -n 1 | awk '{print $5}' @@ -112,10 +121,13 @@ sleep 3 # Check if Serveo tunnel was set up successfully DEPLOYED_URL=$(grep "Forwarding HTTP traffic from" serveo_output.log | tail -n 1 | awk '{print $5}') +# update the nohup ids if [ -n DEPLOYED_URL ]; then - jq --arg pid "$SERVEO_PID" '.serveo = $pid' "$PID_FILE" > tmp.$$.json && mv tmp.$$.json "$PID_FILE" + # jq --arg pid "$SERVEO_PID" '.serveo = $pid' "$PID_FILE" > tmp.$$.json && mv tmp.$$.json "$PID_FILE" + jq --arg pr_id "$PR_ID" --arg pid "$SERVEO_PID" '.[$pr_id] = $pid' "$PID_FILE" > tmp.$$.json && mv tmp.$$.json "$PID_FILE" + fi # Output the final JSON -echo "{\"COMMENT_ID\": \"$COMMENT_ID\", \"DEPLOYED_URL\": \"$DEPLOYED_URL\", \"SERVEO_PID\": \"$SERVEO_PID\"}" +echo "{\"COMMENT_ID\": \"$COMMENT_ID\", \"DEPLOYED_URL\": \"$DEPLOYED_URL\"}" From a8cf5e9ba091b1327634c2699a8d5dd0032d6ac9 Mon Sep 17 00:00:00 2001 From: Dominic Date: Wed, 31 Jul 2024 21:06:30 +0100 Subject: [PATCH 07/51] Update pr-deploy.sh Signed-off-by: Dominic --- pr-deploy.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pr-deploy.sh b/pr-deploy.sh index 321cdbe1..8358a523 100644 --- a/pr-deploy.sh +++ b/pr-deploy.sh @@ -104,8 +104,8 @@ if [ ! -f "$PID_FILE" ]; then fi # Initialize the JSON file for comment if it doesn't exist -if [ ! -f "$COMMENT_FILE" ]; then - echo "{}" > "$COMMENT_FILE" +if [ ! -f "$COMMENT_ID_FILE" ]; then + echo "{}" > "$COMMENT_ID_FILE" fi # function to check if serveo was successful From 241b7c5a66cf21a51f73f32e0c330571023b324a Mon Sep 17 00:00:00 2001 From: Dominic Date: Wed, 31 Jul 2024 21:17:00 +0100 Subject: [PATCH 08/51] Update pr-deploy.sh Signed-off-by: Dominic --- pr-deploy.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pr-deploy.sh b/pr-deploy.sh index 8358a523..3446cfa1 100644 --- a/pr-deploy.sh +++ b/pr-deploy.sh @@ -61,7 +61,8 @@ if [ -n "$COMMENT_ID" ]; then jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = $cid' "$COMMENT_ID_FILE" > tmp.$$.json && mv tmp.$$.json "$COMMENT_ID_FILE" else if [ -f "$COMMENT_ID_FILE" ]; then - COMMENT_ID=$(jq -r --arg key "$PR_ID" '.[$key]' "$COMMENT_ID_FILE") + COMMENT_ID=$(jq -r --arg key "$PR_ID" '.[$key]' "${COMMENT_ID_FILE}") + else COMMENT_ID="" fi From d8d5aac4fe914a03f968b9a8a16cbc22bbd6599f Mon Sep 17 00:00:00 2001 From: Dominic Date: Wed, 31 Jul 2024 21:18:15 +0100 Subject: [PATCH 09/51] Update entrypoint.sh Signed-off-by: Dominic --- entrypoint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/entrypoint.sh b/entrypoint.sh index a6a21a5c..e725566e 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -74,6 +74,7 @@ SANITIZED_OUTPUT=$(echo "$REMOTE_OUTPUT" | sed 's/[[:cntrl:]]//g') COMMENT_ID=$(echo "$SANITIZED_OUTPUT" | jq -r '.COMMENT_ID') DEPLOYED_URL=$(echo "$SANITIZED_OUTPUT" | jq -r '.DEPLOYED_URL') +echo $COMMENT_ID # TO BE REMOVED LATER echo "$SANITIZED_OUTPUT" | jq -r '.SERVEO_PID' From fc36d2770f1b94c6e284567e4f5a29c6765501d3 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Wed, 31 Jul 2024 21:47:57 +0100 Subject: [PATCH 10/51] Update deploy.yml Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- .github/workflows/deploy.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index aabfd325..39995c39 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,7 +1,6 @@ name: PR Deploy on: - pull_request: - types: [opened, reopened, synchronize, closed] + pull_request jobs: deploy: From 43323aa5c7a40265dc1cedbec17f93103cc8496a Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Wed, 31 Jul 2024 21:52:57 +0100 Subject: [PATCH 11/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index e725566e..4526872e 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -56,6 +56,8 @@ REPO_ID=$(curl -L \ -H "Authorization: Bearer $GITHUB_TOKEN" \ https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME} | jq -r '.id') +echo "pr action >> $PR_ACTION" + # Checks if the action is opened if [ "$PR_ACTION" == "opened" ]; then comment "Deploying ⏳" "#" From 5ee75b363fa41e2fa9931e10d9b870f86be046ce Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Wed, 31 Jul 2024 22:26:33 +0100 Subject: [PATCH 12/51] Update pr-deploy.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- pr-deploy.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pr-deploy.sh b/pr-deploy.sh index 3446cfa1..0709fb9c 100644 --- a/pr-deploy.sh +++ b/pr-deploy.sh @@ -13,8 +13,8 @@ PR_NUMBER=$8 COMMENT_ID=$9 PR_ID="pr_${REPO_ID}${PR_NUMBER}" # JSON file to store PIDs -PID_FILE="/srv/pr-deploy/nohup_pids.json" -COMMENT_ID_FILE="/srv/pr-deploy/comment_ids.json" +PID_FILE="/srv/pr-deploy/nohup.json" +COMMENT_ID_FILE="/srv/pr-deploy/comments.json" DEPLOY_FOLDER="/srv/pr-deploy" function handle_error { From 76123815f88ac13d0f6a792d1b3b9f9b8c9ec2dc Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Wed, 31 Jul 2024 22:28:03 +0100 Subject: [PATCH 13/51] Update deploy.yml Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- .github/workflows/deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 39995c39..fe21a780 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,6 +1,7 @@ name: PR Deploy on: - pull_request + pull_request: + types: [opened, closed, synchronize, reopened] jobs: deploy: From 10bb0b25f4f21ca4ab46843d0b2781f6348f7ffa Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Wed, 31 Jul 2024 22:33:03 +0100 Subject: [PATCH 14/51] Update login.html Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- website/templates/login.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/templates/login.html b/website/templates/login.html index 4f67e1b8..76667223 100644 --- a/website/templates/login.html +++ b/website/templates/login.html @@ -1,7 +1,7 @@ {% extends "base.html" %} {% block title %}Login{% endblock %} {% block content %}
-

Login

+

New Login

Date: Wed, 31 Jul 2024 22:42:58 +0100 Subject: [PATCH 15/51] Update Dockerfile Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f4287a3b..4c5bf107 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,4 +7,6 @@ RUN pip3 install -r requirements.txt COPY . . -CMD [ "python3", "-m" , "flask", "--app", "main.py", "run", "--host=0.0.0.0", "--port=5000"] \ No newline at end of file +EXPOSE 5000:5000 + +CMD [ "python3", "-m" , "flask", "--app", "main.py", "run", "--host=0.0.0.0", "--port=5000"] From fd10bcafa7fea6a3f165ceffb2da479f7b54245c Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Wed, 31 Jul 2024 22:56:18 +0100 Subject: [PATCH 16/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 4526872e..38d73956 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -28,7 +28,7 @@ comment() { - PR Deploy + PR Deploy ${status_message} Visit Preview $(date +'%b %d, %Y %I:%M%p') From a92f92e63f68033f5cb56eaf85da24fa752be0aa Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Wed, 31 Jul 2024 22:57:11 +0100 Subject: [PATCH 17/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 38d73956..5e663f81 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -56,8 +56,6 @@ REPO_ID=$(curl -L \ -H "Authorization: Bearer $GITHUB_TOKEN" \ https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME} | jq -r '.id') -echo "pr action >> $PR_ACTION" - # Checks if the action is opened if [ "$PR_ACTION" == "opened" ]; then comment "Deploying ⏳" "#" From 66af57f758ee217dc6ef5ba3029e983df838f344 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Wed, 31 Jul 2024 23:05:08 +0100 Subject: [PATCH 18/51] Update pr-deploy.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- pr-deploy.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/pr-deploy.sh b/pr-deploy.sh index 0709fb9c..68cdf67b 100644 --- a/pr-deploy.sh +++ b/pr-deploy.sh @@ -29,6 +29,7 @@ function kill_process_with_pid() { ID=$(jq -r --arg key "$key" '.[$key]' "${PID_FILE}") if [ -n $ID ]; then kill -9 $ID + jq --arg key "$key" 'del(.[$key])' "${PID_FILE}" > tmp && mv tmp "${PID_FILE}" fi } From 3784d1cb6f28867125814c6b649c1af0b2904e94 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Wed, 31 Jul 2024 23:15:03 +0100 Subject: [PATCH 19/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 5e663f81..4b5f7e20 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -74,10 +74,6 @@ SANITIZED_OUTPUT=$(echo "$REMOTE_OUTPUT" | sed 's/[[:cntrl:]]//g') COMMENT_ID=$(echo "$SANITIZED_OUTPUT" | jq -r '.COMMENT_ID') DEPLOYED_URL=$(echo "$SANITIZED_OUTPUT" | jq -r '.DEPLOYED_URL') -echo $COMMENT_ID -# TO BE REMOVED LATER -echo "$SANITIZED_OUTPUT" | jq -r '.SERVEO_PID' - if [ -z "$DEPLOYED_URL" ]; then if [ "$PR_ACTION" == "closed" ]; then comment "Terminated 🛑" "#" && exit 0 From 2518d7a611c8bca2d5720faf53cacf62bf528251 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Wed, 31 Jul 2024 23:19:28 +0100 Subject: [PATCH 20/51] Update pr-deploy.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- pr-deploy.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pr-deploy.sh b/pr-deploy.sh index 68cdf67b..50fa1b2d 100644 --- a/pr-deploy.sh +++ b/pr-deploy.sh @@ -33,6 +33,16 @@ function kill_process_with_pid() { fi } +# Initialize the JSON file for nohup if it doesn't exist +if [ ! -f "$PID_FILE" ]; then + echo "{}" > "$PID_FILE" +fi + +# Initialize the JSON file for comment if it doesn't exist +if [ ! -f "$COMMENT_ID_FILE" ]; then + echo "{}" > "$COMMENT_ID_FILE" +fi + # Set up trap to handle errors trap 'handle_error' ERR @@ -100,16 +110,6 @@ sudo docker run -d -p $FREE_PORT:$EXPOSED_PORT --name $PR_ID $PR_ID echo "Start SSH session..." -# Initialize the JSON file for nohup if it doesn't exist -if [ ! -f "$PID_FILE" ]; then - echo "{}" > "$PID_FILE" -fi - -# Initialize the JSON file for comment if it doesn't exist -if [ ! -f "$COMMENT_ID_FILE" ]; then - echo "{}" > "$COMMENT_ID_FILE" -fi - # function to check if serveo was successful # check_serveo() { # grep "Forwarding HTTP traffic from" serveo_output.log | tail -n 1 | awk '{print $5}' From 771501958d8708d40ec34793e17a856dbf46b24a Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Wed, 31 Jul 2024 23:24:13 +0100 Subject: [PATCH 21/51] Update login.html Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- website/templates/login.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/templates/login.html b/website/templates/login.html index 76667223..811d6638 100644 --- a/website/templates/login.html +++ b/website/templates/login.html @@ -1,7 +1,7 @@ {% extends "base.html" %} {% block title %}Login{% endblock %} {% block content %} -

New Login

+

Test Login

Date: Wed, 31 Jul 2024 23:52:17 +0100 Subject: [PATCH 22/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 4b5f7e20..8f47e4d6 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -74,6 +74,15 @@ SANITIZED_OUTPUT=$(echo "$REMOTE_OUTPUT" | sed 's/[[:cntrl:]]//g') COMMENT_ID=$(echo "$SANITIZED_OUTPUT" | jq -r '.COMMENT_ID') DEPLOYED_URL=$(echo "$SANITIZED_OUTPUT" | jq -r '.DEPLOYED_URL') +if [ -z "$COMMENT_ID" ]; then + # Checks if the action is opened + if [[ "$PR_ACTION" == "opened" || "$PR_ACTION" == "synchronize" || "$PR_ACTION" == "reopened" ]]; then + comment "Deploying ⏳" "#" + elif [ "$PR_ACTION" == "closed" ]; then + comment "Terminated 🛑" "#" && exit 0 + fi +fi + if [ -z "$DEPLOYED_URL" ]; then if [ "$PR_ACTION" == "closed" ]; then comment "Terminated 🛑" "#" && exit 0 From 4509e99bd69ce2ebcc7668d0c8cc77f2d6afc695 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:03:42 +0100 Subject: [PATCH 23/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 8f47e4d6..99be7ecd 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -74,6 +74,8 @@ SANITIZED_OUTPUT=$(echo "$REMOTE_OUTPUT" | sed 's/[[:cntrl:]]//g') COMMENT_ID=$(echo "$SANITIZED_OUTPUT" | jq -r '.COMMENT_ID') DEPLOYED_URL=$(echo "$SANITIZED_OUTPUT" | jq -r '.DEPLOYED_URL') +echo "commentId >> $COMMENT_ID" + if [ -z "$COMMENT_ID" ]; then # Checks if the action is opened if [[ "$PR_ACTION" == "opened" || "$PR_ACTION" == "synchronize" || "$PR_ACTION" == "reopened" ]]; then From 8c15849dfe4a9f73e53c2c11d1c2bb0a10579c8c Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:06:29 +0100 Subject: [PATCH 24/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 99be7ecd..1483874d 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -76,7 +76,7 @@ DEPLOYED_URL=$(echo "$SANITIZED_OUTPUT" | jq -r '.DEPLOYED_URL') echo "commentId >> $COMMENT_ID" -if [ -z "$COMMENT_ID" ]; then +if [ "$COMMENT_ID" == "null" ]; then # Checks if the action is opened if [[ "$PR_ACTION" == "opened" || "$PR_ACTION" == "synchronize" || "$PR_ACTION" == "reopened" ]]; then comment "Deploying ⏳" "#" From 4585e0cdada0f47ae394013c7f7e26aed12aef43 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:10:14 +0100 Subject: [PATCH 25/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/entrypoint.sh b/entrypoint.sh index 1483874d..5213788f 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -77,6 +77,7 @@ DEPLOYED_URL=$(echo "$SANITIZED_OUTPUT" | jq -r '.DEPLOYED_URL') echo "commentId >> $COMMENT_ID" if [ "$COMMENT_ID" == "null" ]; then + COMMENT_ID="" # Checks if the action is opened if [[ "$PR_ACTION" == "opened" || "$PR_ACTION" == "synchronize" || "$PR_ACTION" == "reopened" ]]; then comment "Deploying ⏳" "#" From 7110327fa0ac3d4ea9cd4a7f68f56f12abfe1d6a Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:23:49 +0100 Subject: [PATCH 26/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 5213788f..5d6771dc 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -42,6 +42,18 @@ comment() { -d "$comment_body" \ -H "Accept: application/vnd.github.v3+json" \ "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/issues/${PR_NUMBER}/comments" | jq -r '.id') + + elif [ "$COMMENT_ID" == "null" ]; then + # Create a new comment + COMMENT_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" -X POST \ + -d "$comment_body" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/issues/${PR_NUMBER}/comments" | jq -r '.id') + + COMMENT_ID_FILE="/srv/pr-deploy/comments.json" + PR_ID="pr_${REPO_ID}${PR_NUMBER}" + # Run the pr-deploy.sh script to update the comments.json file + sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = $cid' "$COMMENT_ID_FILE" > tmp.$$.json && mv tmp.$$.json "$COMMENT_ID_FILE" else # Update an existing comment curl -s -H "Authorization: token $GITHUB_TOKEN" -X PATCH \ @@ -77,7 +89,6 @@ DEPLOYED_URL=$(echo "$SANITIZED_OUTPUT" | jq -r '.DEPLOYED_URL') echo "commentId >> $COMMENT_ID" if [ "$COMMENT_ID" == "null" ]; then - COMMENT_ID="" # Checks if the action is opened if [[ "$PR_ACTION" == "opened" || "$PR_ACTION" == "synchronize" || "$PR_ACTION" == "reopened" ]]; then comment "Deploying ⏳" "#" From 73ead2e94c97fbadb35a8d2886f60e474993e057 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:27:43 +0100 Subject: [PATCH 27/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 5d6771dc..088a91b4 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -53,7 +53,9 @@ comment() { COMMENT_ID_FILE="/srv/pr-deploy/comments.json" PR_ID="pr_${REPO_ID}${PR_NUMBER}" # Run the pr-deploy.sh script to update the comments.json file - sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = $cid' "$COMMENT_ID_FILE" > tmp.$$.json && mv tmp.$$.json "$COMMENT_ID_FILE" + # sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = $cid' "$COMMENT_ID_FILE" > tmp.$$.json && mv tmp.$$.json "$COMMENT_ID_FILE" + sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash -c "jq --arg pr_id \"$PR_ID\" --arg cid \"$COMMENT_ID\" '.[$pr_id] = \$cid' \"$COMMENT_ID_FILE\" > tmp.\$\$.json && mv tmp.\$\$.json \"$COMMENT_ID_FILE\"" + else # Update an existing comment curl -s -H "Authorization: token $GITHUB_TOKEN" -X PATCH \ From 994811ba8a331a8f990738eaaa0a7c1ae84657eb Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:37:28 +0100 Subject: [PATCH 28/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 088a91b4..012054ee 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -53,9 +53,11 @@ comment() { COMMENT_ID_FILE="/srv/pr-deploy/comments.json" PR_ID="pr_${REPO_ID}${PR_NUMBER}" # Run the pr-deploy.sh script to update the comments.json file - # sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = $cid' "$COMMENT_ID_FILE" > tmp.$$.json && mv tmp.$$.json "$COMMENT_ID_FILE" - sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash -c "jq --arg pr_id \"$PR_ID\" --arg cid \"$COMMENT_ID\" '.[$pr_id] = \$cid' \"$COMMENT_ID_FILE\" > tmp.\$\$.json && mv tmp.\$\$.json \"$COMMENT_ID_FILE\"" - + #sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = $cid' "$COMMENT_ID_FILE" > tmp.$$.json && mv tmp.$$.json "$COMMENT_ID_FILE" + # sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash -c "jq --arg pr_id \"$PR_ID\" --arg cid \"$COMMENT_ID\" '.[$pr_id] = \$cid' \"$COMMENT_ID_FILE\" > tmp.\$\$.json && mv tmp.\$\$.json \"$COMMENT_ID_FILE\"" + sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST < tmp.\$\$.json && mv tmp.\$\$.json "$COMMENT_ID_FILE" +EOF else # Update an existing comment curl -s -H "Authorization: token $GITHUB_TOKEN" -X PATCH \ From c58bc8782307db09af7d1538a7562b6bcd6363c2 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:45:05 +0100 Subject: [PATCH 29/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 012054ee..9f4b5005 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -56,6 +56,10 @@ comment() { #sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = $cid' "$COMMENT_ID_FILE" > tmp.$$.json && mv tmp.$$.json "$COMMENT_ID_FILE" # sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash -c "jq --arg pr_id \"$PR_ID\" --arg cid \"$COMMENT_ID\" '.[$pr_id] = \$cid' \"$COMMENT_ID_FILE\" > tmp.\$\$.json && mv tmp.\$\$.json \"$COMMENT_ID_FILE\"" sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST < "$COMMENT_ID_FILE" + fi + jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = \$cid' "$COMMENT_ID_FILE" > tmp.\$\$.json && mv tmp.\$\$.json "$COMMENT_ID_FILE" EOF else From 20d037441f6b62fea808dbe564d08b330a618003 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:53:11 +0100 Subject: [PATCH 30/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 9f4b5005..625b8c32 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -105,6 +105,8 @@ if [ "$COMMENT_ID" == "null" ]; then fi fi +echo "commentId2 >> $COMMENT_ID" + if [ -z "$DEPLOYED_URL" ]; then if [ "$PR_ACTION" == "closed" ]; then comment "Terminated 🛑" "#" && exit 0 From 3361e37eaf716beb6b3eae0947d3b564472bb23f Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:55:59 +0100 Subject: [PATCH 31/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 625b8c32..015ede79 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -60,7 +60,7 @@ comment() { echo "{}" > "$COMMENT_ID_FILE" fi - jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = \$cid' "$COMMENT_ID_FILE" > tmp.\$\$.json && mv tmp.\$\$.json "$COMMENT_ID_FILE" + jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = \$cid' "$COMMENT_ID_FILE" > tmp.$$.json && mv tmp.$$.json "$COMMENT_ID_FILE" EOF else # Update an existing comment From 98f50dc1595a088d30f236dd8c6b664e76d125e0 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 01:00:28 +0100 Subject: [PATCH 32/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 015ede79..625b8c32 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -60,7 +60,7 @@ comment() { echo "{}" > "$COMMENT_ID_FILE" fi - jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = \$cid' "$COMMENT_ID_FILE" > tmp.$$.json && mv tmp.$$.json "$COMMENT_ID_FILE" + jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = \$cid' "$COMMENT_ID_FILE" > tmp.\$\$.json && mv tmp.\$\$.json "$COMMENT_ID_FILE" EOF else # Update an existing comment From 41e93e5f9a0face96749ca1d08e3159264003b64 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 01:04:20 +0100 Subject: [PATCH 33/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 625b8c32..dbfba478 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -60,7 +60,7 @@ comment() { echo "{}" > "$COMMENT_ID_FILE" fi - jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = \$cid' "$COMMENT_ID_FILE" > tmp.\$\$.json && mv tmp.\$\$.json "$COMMENT_ID_FILE" + jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = $cid' "$COMMENT_ID_FILE" > tmp.\$\$.json && mv tmp.\$\$.json "$COMMENT_ID_FILE" EOF else # Update an existing comment From 1d8a04dd828a968180dee7a15926983e0e3d8286 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 01:11:38 +0100 Subject: [PATCH 34/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index dbfba478..e71d3156 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -55,13 +55,34 @@ comment() { # Run the pr-deploy.sh script to update the comments.json file #sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = $cid' "$COMMENT_ID_FILE" > tmp.$$.json && mv tmp.$$.json "$COMMENT_ID_FILE" # sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash -c "jq --arg pr_id \"$PR_ID\" --arg cid \"$COMMENT_ID\" '.[$pr_id] = \$cid' \"$COMMENT_ID_FILE\" > tmp.\$\$.json && mv tmp.\$\$.json \"$COMMENT_ID_FILE\"" - sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST < "$COMMENT_ID_FILE" - fi +# sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST < "$COMMENT_ID_FILE" +# fi - jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = $cid' "$COMMENT_ID_FILE" > tmp.\$\$.json && mv tmp.\$\$.json "$COMMENT_ID_FILE" +# jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = $cid' "$COMMENT_ID_FILE" > tmp.\$\$.json && mv tmp.\$\$.json "$COMMENT_ID_FILE" +# EOF + +sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST < "$COMMENT_ID_FILE" + fi + + # Debugging: Output the PR_ID and COMMENT_ID + echo "PR_ID: $PR_ID" >> "./debugging.log" + echo "COMMENT_ID: $COMMENT_ID" >> "./debugging.log" + + # Run jq command to update the JSON file + jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = \$cid' "$COMMENT_ID_FILE" > tmp.\$\$.json && mv tmp.\$\$.json "$COMMENT_ID_FILE" + + # Debugging: Check the content of the file after update + cat "$COMMENT_ID_FILE" >> "./debugging.log" EOF + else # Update an existing comment curl -s -H "Authorization: token $GITHUB_TOKEN" -X PATCH \ From 8b4466b29c8c2d28ad7e4bf5d7c060b81f1581c0 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 01:24:21 +0100 Subject: [PATCH 35/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index e71d3156..c19f39f2 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -63,26 +63,27 @@ comment() { # jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = $cid' "$COMMENT_ID_FILE" > tmp.\$\$.json && mv tmp.\$\$.json "$COMMENT_ID_FILE" # EOF +# sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST < "$COMMENT_ID_FILE" +# fi + +# # Run jq command to update the JSON file +# jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = \$cid' "$COMMENT_ID_FILE" > tmp.\$\$.json && mv tmp.\$\$.json "$COMMENT_ID_FILE" +# EOF + sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST < "$COMMENT_ID_FILE" fi - # Debugging: Output the PR_ID and COMMENT_ID - echo "PR_ID: $PR_ID" >> "./debugging.log" - echo "COMMENT_ID: $COMMENT_ID" >> "./debugging.log" - # Run jq command to update the JSON file - jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = \$cid' "$COMMENT_ID_FILE" > tmp.\$\$.json && mv tmp.\$\$.json "$COMMENT_ID_FILE" - - # Debugging: Check the content of the file after update - cat "$COMMENT_ID_FILE" >> "./debugging.log" + jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = $cid' "$COMMENT_ID_FILE" > tmp.\$\$.json && mv tmp.\$\$.json "$COMMENT_ID_FILE" EOF + else # Update an existing comment curl -s -H "Authorization: token $GITHUB_TOKEN" -X PATCH \ From 1d862b32943a5c19b4a6e706385296d01e843bd6 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 01:30:02 +0100 Subject: [PATCH 36/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index c19f39f2..21760c8b 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,6 +2,7 @@ # Exit immediately if a command exits with a non-zero status. set -e +UPDATE_COMMENT_ID=false function handle_error { comment "Failed ❌" "#" && exit 1 @@ -50,18 +51,7 @@ comment() { -H "Accept: application/vnd.github.v3+json" \ "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/issues/${PR_NUMBER}/comments" | jq -r '.id') - COMMENT_ID_FILE="/srv/pr-deploy/comments.json" - PR_ID="pr_${REPO_ID}${PR_NUMBER}" - # Run the pr-deploy.sh script to update the comments.json file - #sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = $cid' "$COMMENT_ID_FILE" > tmp.$$.json && mv tmp.$$.json "$COMMENT_ID_FILE" - # sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash -c "jq --arg pr_id \"$PR_ID\" --arg cid \"$COMMENT_ID\" '.[$pr_id] = \$cid' \"$COMMENT_ID_FILE\" > tmp.\$\$.json && mv tmp.\$\$.json \"$COMMENT_ID_FILE\"" -# sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST < "$COMMENT_ID_FILE" -# fi - -# jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = $cid' "$COMMENT_ID_FILE" > tmp.\$\$.json && mv tmp.\$\$.json "$COMMENT_ID_FILE" -# EOF + UPDATE_COMMENT_ID=true # sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST < tmp.\$\$.json && mv tmp.\$\$.json "$COMMENT_ID_FILE" # EOF -sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST < "$COMMENT_ID_FILE" - fi - - # Run jq command to update the JSON file - jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = $cid' "$COMMENT_ID_FILE" > tmp.\$\$.json && mv tmp.\$\$.json "$COMMENT_ID_FILE" -EOF - - else # Update an existing comment curl -s -H "Authorization: token $GITHUB_TOKEN" -X PATCH \ @@ -107,7 +86,7 @@ fi sshpass -p "$SERVER_PASSWORD" scp -o StrictHostKeyChecking=no -P $SERVER_PORT pr-deploy.sh $SERVER_USERNAME@$SERVER_HOST:/srv/pr-deploy.sh # Run the pr-deploy.sh script on the remote server and capture the output from the remote script -REMOTE_OUTPUT=$(sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash /srv/pr-deploy.sh $CONTEXT $DOCKERFILE $EXPOSED_PORT $REPO_URL $REPO_ID $GITHUB_HEAD_REF $PR_ACTION $PR_NUMBER $COMMENT_ID | tail -n 1) +REMOTE_OUTPUT=$(sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash /srv/pr-deploy.sh $CONTEXT $DOCKERFILE $EXPOSED_PORT $REPO_URL $REPO_ID $GITHUB_HEAD_REF $PR_ACTION $PR_NUMBER $COMMENT_ID $UPDATE_COMMENT_ID | tail -n 1) # Ensure the output is valid JSON by escaping problematic characters SANITIZED_OUTPUT=$(echo "$REMOTE_OUTPUT" | sed 's/[[:cntrl:]]//g') From d4e028d531c4f8bdf7c079d58635ec33d0e28949 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 01:36:38 +0100 Subject: [PATCH 37/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 21760c8b..59db8edf 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -53,6 +53,9 @@ comment() { UPDATE_COMMENT_ID=true + # Run the pr-deploy.sh script on the remote server and capture the output from the remote script + NEW_REMOTE_OUTPUT=$(sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash /srv/pr-deploy.sh $CONTEXT $DOCKERFILE $EXPOSED_PORT $REPO_URL $REPO_ID $GITHUB_HEAD_REF $PR_ACTION $PR_NUMBER $COMMENT_ID $UPDATE_COMMENT_ID | tail -n 1) + # sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST < Date: Thu, 1 Aug 2024 01:36:52 +0100 Subject: [PATCH 38/51] Update pr-deploy.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- pr-deploy.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pr-deploy.sh b/pr-deploy.sh index 50fa1b2d..8af6ebe8 100644 --- a/pr-deploy.sh +++ b/pr-deploy.sh @@ -16,6 +16,7 @@ PR_ID="pr_${REPO_ID}${PR_NUMBER}" PID_FILE="/srv/pr-deploy/nohup.json" COMMENT_ID_FILE="/srv/pr-deploy/comments.json" DEPLOY_FOLDER="/srv/pr-deploy" +UPDATE_COMMENT_ID=${10} function handle_error { echo "{\"COMMENT_ID\": \"$COMMENT_ID\", \"DEPLOYED_URL\": \"\"}" @@ -66,6 +67,16 @@ mkdir -p ${DEPLOY_FOLDER}/ cd ${DEPLOY_FOLDER} rm -rf $PR_ID +# Handle UPDATE_COMMENT_ID +if [ "$UPDATE_COMMENT_ID" == "true" ]; then + if [ ! -f "$COMMENT_ID_FILE" ] || [ ! -s "$COMMENT_ID_FILE" ]; then + echo "{}" > "$COMMENT_ID_FILE" + fi + + # Run jq command to update the JSON file + jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = $cid' "$COMMENT_ID_FILE" > tmp.$$.json && mv tmp.$$.json "$COMMENT_ID_FILE" +fi + # Handle COMMENT_ID if [ -n "$COMMENT_ID" ]; then # echo "$COMMENT_ID" > "${PR_ID}.txt" From 5f9c0bee55f273a145465abb70b523b2f076e36b Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 01:43:09 +0100 Subject: [PATCH 39/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 59db8edf..bf651b63 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -51,10 +51,10 @@ comment() { -H "Accept: application/vnd.github.v3+json" \ "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/issues/${PR_NUMBER}/comments" | jq -r '.id') - UPDATE_COMMENT_ID=true + # UPDATE_COMMENT_ID=true - # Run the pr-deploy.sh script on the remote server and capture the output from the remote script - NEW_REMOTE_OUTPUT=$(sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash /srv/pr-deploy.sh $CONTEXT $DOCKERFILE $EXPOSED_PORT $REPO_URL $REPO_ID $GITHUB_HEAD_REF $PR_ACTION $PR_NUMBER $COMMENT_ID $UPDATE_COMMENT_ID | tail -n 1) + # # Run the pr-deploy.sh script on the remote server and capture the output from the remote script + # NEW_REMOTE_OUTPUT=$(sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash /srv/pr-deploy.sh $CONTEXT $DOCKERFILE $EXPOSED_PORT $REPO_URL $REPO_ID $GITHUB_HEAD_REF $PR_ACTION $PR_NUMBER $COMMENT_ID $UPDATE_COMMENT_ID | tail -n 1) # sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST <> $COMMENT_ID" + echo "commentId2 >> $COMMENT_ID" + + UPDATE_COMMENT_ID=true + + # Run the pr-deploy.sh script on the remote server and capture the output from the remote script + NEW_REMOTE_OUTPUT=$(sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash /srv/pr-deploy.sh $CONTEXT $DOCKERFILE $EXPOSED_PORT $REPO_URL $REPO_ID $GITHUB_HEAD_REF $PR_ACTION $PR_NUMBER $COMMENT_ID $UPDATE_COMMENT_ID | tail -n 1) +fi if [ -z "$DEPLOYED_URL" ]; then if [ "$PR_ACTION" == "closed" ]; then From 740a4bb7a911077b3321fc568cbd08c36b7f8424 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 01:46:28 +0100 Subject: [PATCH 40/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index bf651b63..96dca3ae 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -107,8 +107,6 @@ if [ "$COMMENT_ID" == "null" ]; then elif [ "$PR_ACTION" == "closed" ]; then comment "Terminated 🛑" "#" && exit 0 fi - - echo "commentId2 >> $COMMENT_ID" UPDATE_COMMENT_ID=true @@ -116,6 +114,8 @@ if [ "$COMMENT_ID" == "null" ]; then NEW_REMOTE_OUTPUT=$(sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash /srv/pr-deploy.sh $CONTEXT $DOCKERFILE $EXPOSED_PORT $REPO_URL $REPO_ID $GITHUB_HEAD_REF $PR_ACTION $PR_NUMBER $COMMENT_ID $UPDATE_COMMENT_ID | tail -n 1) fi +echo "commentId2 >> $COMMENT_ID" + if [ -z "$DEPLOYED_URL" ]; then if [ "$PR_ACTION" == "closed" ]; then comment "Terminated 🛑" "#" && exit 0 From 5cab86ba2f0a1720b4a3899c1bd6f29647cdee81 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 01:50:20 +0100 Subject: [PATCH 41/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 96dca3ae..a60f7fc0 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,7 +2,7 @@ # Exit immediately if a command exits with a non-zero status. set -e -UPDATE_COMMENT_ID=false +UPDATE_COMMENT_ID="666" function handle_error { comment "Failed ❌" "#" && exit 1 From c38ccbf68fa281642d40c0e470eb558c0fa0a4e4 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 02:05:50 +0100 Subject: [PATCH 42/51] Update pr-deploy.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- pr-deploy.sh | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/pr-deploy.sh b/pr-deploy.sh index 8af6ebe8..50fa1b2d 100644 --- a/pr-deploy.sh +++ b/pr-deploy.sh @@ -16,7 +16,6 @@ PR_ID="pr_${REPO_ID}${PR_NUMBER}" PID_FILE="/srv/pr-deploy/nohup.json" COMMENT_ID_FILE="/srv/pr-deploy/comments.json" DEPLOY_FOLDER="/srv/pr-deploy" -UPDATE_COMMENT_ID=${10} function handle_error { echo "{\"COMMENT_ID\": \"$COMMENT_ID\", \"DEPLOYED_URL\": \"\"}" @@ -67,16 +66,6 @@ mkdir -p ${DEPLOY_FOLDER}/ cd ${DEPLOY_FOLDER} rm -rf $PR_ID -# Handle UPDATE_COMMENT_ID -if [ "$UPDATE_COMMENT_ID" == "true" ]; then - if [ ! -f "$COMMENT_ID_FILE" ] || [ ! -s "$COMMENT_ID_FILE" ]; then - echo "{}" > "$COMMENT_ID_FILE" - fi - - # Run jq command to update the JSON file - jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = $cid' "$COMMENT_ID_FILE" > tmp.$$.json && mv tmp.$$.json "$COMMENT_ID_FILE" -fi - # Handle COMMENT_ID if [ -n "$COMMENT_ID" ]; then # echo "$COMMENT_ID" > "${PR_ID}.txt" From 5d72319c10880daf164a3c411106615cf2c312d3 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 02:09:38 +0100 Subject: [PATCH 43/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index a60f7fc0..ab275bc6 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,7 +2,6 @@ # Exit immediately if a command exits with a non-zero status. set -e -UPDATE_COMMENT_ID="666" function handle_error { comment "Failed ❌" "#" && exit 1 @@ -89,7 +88,7 @@ fi sshpass -p "$SERVER_PASSWORD" scp -o StrictHostKeyChecking=no -P $SERVER_PORT pr-deploy.sh $SERVER_USERNAME@$SERVER_HOST:/srv/pr-deploy.sh # Run the pr-deploy.sh script on the remote server and capture the output from the remote script -REMOTE_OUTPUT=$(sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash /srv/pr-deploy.sh $CONTEXT $DOCKERFILE $EXPOSED_PORT $REPO_URL $REPO_ID $GITHUB_HEAD_REF $PR_ACTION $PR_NUMBER $COMMENT_ID $UPDATE_COMMENT_ID | tail -n 1) +REMOTE_OUTPUT=$(sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash /srv/pr-deploy.sh $CONTEXT $DOCKERFILE $EXPOSED_PORT $REPO_URL $REPO_ID $GITHUB_HEAD_REF $PR_ACTION $PR_NUMBER $COMMENT_ID | tail -n 1) # Ensure the output is valid JSON by escaping problematic characters SANITIZED_OUTPUT=$(echo "$REMOTE_OUTPUT" | sed 's/[[:cntrl:]]//g') @@ -108,14 +107,11 @@ if [ "$COMMENT_ID" == "null" ]; then comment "Terminated 🛑" "#" && exit 0 fi - UPDATE_COMMENT_ID=true - + echo "commentId2 >> $COMMENT_ID" # Run the pr-deploy.sh script on the remote server and capture the output from the remote script - NEW_REMOTE_OUTPUT=$(sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash /srv/pr-deploy.sh $CONTEXT $DOCKERFILE $EXPOSED_PORT $REPO_URL $REPO_ID $GITHUB_HEAD_REF $PR_ACTION $PR_NUMBER $COMMENT_ID $UPDATE_COMMENT_ID | tail -n 1) + NEW_REMOTE_OUTPUT=$(sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash /srv/pr-deploy.sh $CONTEXT $DOCKERFILE $EXPOSED_PORT $REPO_URL $REPO_ID $GITHUB_HEAD_REF $PR_ACTION $PR_NUMBER $COMMENT_ID | tail -n 1) fi -echo "commentId2 >> $COMMENT_ID" - if [ -z "$DEPLOYED_URL" ]; then if [ "$PR_ACTION" == "closed" ]; then comment "Terminated 🛑" "#" && exit 0 From 0944163978c067f4805d60d5df2ab9b298f27bfd Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 02:20:24 +0100 Subject: [PATCH 44/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index ab275bc6..9657f3e7 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -104,12 +104,13 @@ if [ "$COMMENT_ID" == "null" ]; then if [[ "$PR_ACTION" == "opened" || "$PR_ACTION" == "synchronize" || "$PR_ACTION" == "reopened" ]]; then comment "Deploying ⏳" "#" elif [ "$PR_ACTION" == "closed" ]; then - comment "Terminated 🛑" "#" && exit 0 + comment "Terminated 🛑" "#" fi echo "commentId2 >> $COMMENT_ID" # Run the pr-deploy.sh script on the remote server and capture the output from the remote script NEW_REMOTE_OUTPUT=$(sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash /srv/pr-deploy.sh $CONTEXT $DOCKERFILE $EXPOSED_PORT $REPO_URL $REPO_ID $GITHUB_HEAD_REF $PR_ACTION $PR_NUMBER $COMMENT_ID | tail -n 1) + exit 0 fi if [ -z "$DEPLOYED_URL" ]; then From 52be781982d581f97a56c590f2dcb712d8fd41a0 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 02:24:50 +0100 Subject: [PATCH 45/51] Update entrypoint.sh Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- entrypoint.sh | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 9657f3e7..30c73fce 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -49,22 +49,6 @@ comment() { -d "$comment_body" \ -H "Accept: application/vnd.github.v3+json" \ "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/issues/${PR_NUMBER}/comments" | jq -r '.id') - - # UPDATE_COMMENT_ID=true - - # # Run the pr-deploy.sh script on the remote server and capture the output from the remote script - # NEW_REMOTE_OUTPUT=$(sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash /srv/pr-deploy.sh $CONTEXT $DOCKERFILE $EXPOSED_PORT $REPO_URL $REPO_ID $GITHUB_HEAD_REF $PR_ACTION $PR_NUMBER $COMMENT_ID $UPDATE_COMMENT_ID | tail -n 1) - -# sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST < "$COMMENT_ID_FILE" -# fi - -# # Run jq command to update the JSON file -# jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = \$cid' "$COMMENT_ID_FILE" > tmp.\$\$.json && mv tmp.\$\$.json "$COMMENT_ID_FILE" -# EOF - else # Update an existing comment curl -s -H "Authorization: token $GITHUB_TOKEN" -X PATCH \ @@ -97,8 +81,6 @@ SANITIZED_OUTPUT=$(echo "$REMOTE_OUTPUT" | sed 's/[[:cntrl:]]//g') COMMENT_ID=$(echo "$SANITIZED_OUTPUT" | jq -r '.COMMENT_ID') DEPLOYED_URL=$(echo "$SANITIZED_OUTPUT" | jq -r '.DEPLOYED_URL') -echo "commentId >> $COMMENT_ID" - if [ "$COMMENT_ID" == "null" ]; then # Checks if the action is opened if [[ "$PR_ACTION" == "opened" || "$PR_ACTION" == "synchronize" || "$PR_ACTION" == "reopened" ]]; then @@ -107,7 +89,6 @@ if [ "$COMMENT_ID" == "null" ]; then comment "Terminated 🛑" "#" fi - echo "commentId2 >> $COMMENT_ID" # Run the pr-deploy.sh script on the remote server and capture the output from the remote script NEW_REMOTE_OUTPUT=$(sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST bash /srv/pr-deploy.sh $CONTEXT $DOCKERFILE $EXPOSED_PORT $REPO_URL $REPO_ID $GITHUB_HEAD_REF $PR_ACTION $PR_NUMBER $COMMENT_ID | tail -n 1) exit 0 From 9a1ec4df7007277ed19f1e0a41210100416d0034 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 02:27:17 +0100 Subject: [PATCH 46/51] Delete instance directory Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- instance/database.db | Bin 16384 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 instance/database.db diff --git a/instance/database.db b/instance/database.db deleted file mode 100644 index c5e92d481e52140eb42b24fa88d371f482ed3589..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI%K~KUk6bJAQh{_U#3*lt)Zf=QDiSfk6i3O)HqznzGWo9#30!-P6Uhxb1bv(Kb z2vO7zu>6~}OJBS0^|xM@4f>rR_US2{P28ByScNGHyC7nW<&s)R>bm^wE9-%Ot~qx6 za8oLOvi!co$_M3-S6Ie9zyR~Xnc^}2@}ZCrLZ$tY=RG4RN=Y~JRAte#EQu+uprwdlFAOZSFoUK>KIpC(0Lg?+k8R Date: Thu, 1 Aug 2024 02:27:32 +0100 Subject: [PATCH 47/51] Delete website directory Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- website/__init__.py | 41 --------- website/__pycache__/__init__.cpython-312.pyc | Bin 2113 -> 0 bytes website/__pycache__/auth.cpython-312.pyc | Bin 4019 -> 0 bytes website/__pycache__/models.cpython-312.pyc | Bin 1779 -> 0 bytes website/__pycache__/views.cpython-312.pyc | Bin 2196 -> 0 bytes website/auth.py | 66 -------------- website/models.py | 18 ---- website/static/index.js | 8 -- website/templates/base.html | 91 ------------------- website/templates/home.html | 21 ----- website/templates/login.html | 28 ------ website/templates/sign_up.html | 48 ---------- website/views.py | 37 -------- 13 files changed, 358 deletions(-) delete mode 100644 website/__init__.py delete mode 100644 website/__pycache__/__init__.cpython-312.pyc delete mode 100644 website/__pycache__/auth.cpython-312.pyc delete mode 100644 website/__pycache__/models.cpython-312.pyc delete mode 100644 website/__pycache__/views.cpython-312.pyc delete mode 100644 website/auth.py delete mode 100644 website/models.py delete mode 100644 website/static/index.js delete mode 100644 website/templates/base.html delete mode 100644 website/templates/home.html delete mode 100644 website/templates/login.html delete mode 100644 website/templates/sign_up.html delete mode 100644 website/views.py diff --git a/website/__init__.py b/website/__init__.py deleted file mode 100644 index 8d24a3dd..00000000 --- a/website/__init__.py +++ /dev/null @@ -1,41 +0,0 @@ -from flask import Flask -from flask_sqlalchemy import SQLAlchemy -from os import path -from flask_login import LoginManager - -db = SQLAlchemy() -DB_NAME = "database.db" - - -def create_app(): - app = Flask(__name__) - app.config['SECRET_KEY'] = 'hjshjhdjah kjshkjdhjs' - app.config['SQLALCHEMY_DATABASE_URI'] = f'sqlite:///{DB_NAME}' - db.init_app(app) - - from .views import views - from .auth import auth - - app.register_blueprint(views, url_prefix='/') - app.register_blueprint(auth, url_prefix='/') - - from .models import User, Note - - with app.app_context(): - db.create_all() - - login_manager = LoginManager() - login_manager.login_view = 'auth.login' - login_manager.init_app(app) - - @login_manager.user_loader - def load_user(id): - return User.query.get(int(id)) - - return app - - -def create_database(app): - if not path.exists('website/' + DB_NAME): - db.create_all(app=app) - print('Created Database!') diff --git a/website/__pycache__/__init__.cpython-312.pyc b/website/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index b6ab30acc8ec4bdb050f10c7cea34b52185b7ed7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2113 zcmah~-D?zA6unK1eBoP4V+@pA$V4V*A)8Bc9MyS?w}rI8biopB zDJ?Nwv}8Mw4seJ^Sh(MEkycD89W>>uD6N_S7(=s4BKVlDCOA)e$1?j0{?t z9JXiSO)ML34(9MkDVr~j8bu?ENi}2|t}$sixZj-2wA`~vh7pc{8h>&KU6XGi7v`q8 z{!!5VmTe9WQ$q#ON3>^?KLszQ;8K4~?x3&v7hpw-b(Izn6+*t&o@-lsLV6@qhV;mD zG=-8GumW~qj^_|~?`VJFYcO%v_;ie&96A(3rZVb){6KI-CL{inxT*1i|a%REEbzcPaV!;Fp5NbF%Hhf+`H#|{Q zol92U#cyev=EW${Mw0Ihk51@AgXag&42}=$7slRyOzA-x`B5HEJCuV)#m#MU8mMZ8 zSbCY@sr*cW_rwbhCZ3ooxwxuQP`^c4n%UwUIFjJm0Z(HDhA+5VXr3#8_Pi7*Yo8OB ze#@lIAD_G95Me4Ic+#Z`CbOQ9#jYphi!MaP=S@Ph?@-co*EdHs8m6NeCU#1NyfIyx zGzukcsFbPLxac}s#wt}z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yA!gyG1`>d_)hDG=}lXqoK9off155$`V3_COcughw~tR!omLC*(mO`nC@E+H zpCJs|c<9Sy+IDap_Y7Rv02jUm{m;PUw?KRb&ey^D=WgKbxgDwY*FA@>I=9_`cYhtb z7F+tXTB^-fwX3l@mw3*L+}Mr-@X2ku+J27-P1d={Q!ega9 z0rWoxFo1+|beQPPx94@`T+s0hGEebhPvq_SPJBf>lnfsVY?lva~Px5wLNYxvEHZ_N>Rz0V@+z&DI$vElOjXRWT>J5fFJpY|HPtj@*fbiAkjn;8a% zwNEq0>|j!)zN~Jdm8SxYR0vjOVoMK^jmJKBUPd&riXQ12VhC`6y_y=bFJV zn;fO0Bx$mWB#DM4N!6jHa5*YT8QD&X6f`q>~^=kU2V?i{0M<)oEw0p>=PIU>xr{IX6^7XwGpB^J6LuBY>EN|+0 zxvZxa^@61$%`{R4MYmvTT`S$ZnJOx>@$gHuC94$$r8ZICz$QwuzL8?gRBXb>$pPMh zVKaCP2BCN@-bmCF&Dr+t*6qEo_d_?T3xmj&+H50TPd8VaKeSg{s~xL9@o7KuS#|M^ zX^olIT5EgL`xB|>lh3dGHTmb{i>dv{B6Es;P|G)P9d|st;hk_d(_Q#I^IPVRWPf_D zANyweF1b4F#wM8>vE<4ZEX%w;W-|_X2W3|BwQ?s2xZK zsgF<23JJ06Jp6?L8}fjq;SCEpGmuS=kP)UPye=8#z(<*kaTw>oSx(+#K>bLSu|ma) zY#5t5fizsi#4sIl&?rHQY+_wA)^UaUHAXmtaE`if{2`aF4S`oQwisMGdC`g5LSwnU z+{Dd%8@F)R`?I#UvLBtTE)7N}YouYUS;|2*Y9`k^rN3_FS$+eezM6BbEy8aXFAf6CY5ocoWMC)ZgH{!2A(FnH+|1mOUT9e|Gyz(>ac dpD@qJb*p~s7%=fT<`<^jeRK5{U>m2!e*pwDV-ElT diff --git a/website/__pycache__/views.cpython-312.pyc b/website/__pycache__/views.cpython-312.pyc deleted file mode 100644 index 5596c1bec8d9c95da2f7afef51d8888c85d44352..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M@sIQYAZ)KQ%Kz+ hx_37;m~QNl&gYiKm%bFP2cD^2O22R^#8P~ye*j^lx99)> diff --git a/website/auth.py b/website/auth.py deleted file mode 100644 index 8c65752e..00000000 --- a/website/auth.py +++ /dev/null @@ -1,66 +0,0 @@ -from flask import Blueprint, render_template, request, flash, redirect, url_for -from .models import User -from werkzeug.security import generate_password_hash, check_password_hash -from . import db ##means from __init__.py import db -from flask_login import login_user, login_required, logout_user, current_user - - -auth = Blueprint('auth', __name__) - - -@auth.route('/login', methods=['GET', 'POST']) -def login(): - if request.method == 'POST': - email = request.form.get('email') - password = request.form.get('password') - - user = User.query.filter_by(email=email).first() - if user: - if check_password_hash(user.password, password): - flash('Logged in successfully!', category='success') - login_user(user, remember=True) - return redirect(url_for('views.home')) - else: - flash('Incorrect password, try again.', category='error') - else: - flash('Email does not exist.', category='error') - - return render_template("login.html", user=current_user) - - -@auth.route('/logout') -@login_required -def logout(): - logout_user() - return redirect(url_for('auth.login')) - - -@auth.route('/sign-up', methods=['GET', 'POST']) -def sign_up(): - if request.method == 'POST': - email = request.form.get('email') - first_name = request.form.get('firstName') - password1 = request.form.get('password1') - password2 = request.form.get('password2') - - user = User.query.filter_by(email=email).first() - if user: - flash('Email already exists.', category='error') - elif len(email) < 4: - flash('Email must be greater than 3 characters.', category='error') - elif len(first_name) < 2: - flash('First name must be greater than 1 character.', category='error') - elif password1 != password2: - flash('Passwords don\'t match.', category='error') - elif len(password1) < 7: - flash('Password must be at least 7 characters.', category='error') - else: - new_user = User(email=email, first_name=first_name, password=generate_password_hash( - password1, method='sha256')) - db.session.add(new_user) - db.session.commit() - login_user(new_user, remember=True) - flash('Account created!', category='success') - return redirect(url_for('views.home')) - - return render_template("sign_up.html", user=current_user) diff --git a/website/models.py b/website/models.py deleted file mode 100644 index 79c17e6f..00000000 --- a/website/models.py +++ /dev/null @@ -1,18 +0,0 @@ -from . import db -from flask_login import UserMixin -from sqlalchemy.sql import func - - -class Note(db.Model): - id = db.Column(db.Integer, primary_key=True) - data = db.Column(db.String(10000)) - date = db.Column(db.DateTime(timezone=True), default=func.now()) - user_id = db.Column(db.Integer, db.ForeignKey('user.id')) - - -class User(db.Model, UserMixin): - id = db.Column(db.Integer, primary_key=True) - email = db.Column(db.String(150), unique=True) - password = db.Column(db.String(150)) - first_name = db.Column(db.String(150)) - notes = db.relationship('Note') diff --git a/website/static/index.js b/website/static/index.js deleted file mode 100644 index 136d2123..00000000 --- a/website/static/index.js +++ /dev/null @@ -1,8 +0,0 @@ -function deleteNote(noteId) { - fetch("/delete-note", { - method: "POST", - body: JSON.stringify({ noteId: noteId }), - }).then((_res) => { - window.location.href = "/"; - }); -} diff --git a/website/templates/base.html b/website/templates/base.html deleted file mode 100644 index fbbd3854..00000000 --- a/website/templates/base.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - {% block title %}Home{% endblock %} - - - - - {% with messages = get_flashed_messages(with_categories=true) %} {% if - messages %} {% for category, message in messages %} {% if category == - 'error' %} - - {% else %} - - {% endif %} {% endfor %} {% endif %} {% endwith %} - -
{% block content %} {% endblock %}
- - - - -{% block javascript %} - -{% endblock %} - - diff --git a/website/templates/home.html b/website/templates/home.html deleted file mode 100644 index 0fc5c1d9..00000000 --- a/website/templates/home.html +++ /dev/null @@ -1,21 +0,0 @@ -{% extends "base.html" %} {% block title %}Home{% endblock %} {% block content -%} -

Notes

-
    - {% for note in user.notes %} -
  • - {{ note.data }} - -
  • - {% endfor %} -
- - -
-
- -
- -{% endblock %} diff --git a/website/templates/login.html b/website/templates/login.html deleted file mode 100644 index 811d6638..00000000 --- a/website/templates/login.html +++ /dev/null @@ -1,28 +0,0 @@ -{% extends "base.html" %} {% block title %}Login{% endblock %} {% block content -%} -
-

Test Login

-
- - -
-
- - -
-
- -
-{% endblock %} diff --git a/website/templates/sign_up.html b/website/templates/sign_up.html deleted file mode 100644 index 0d401e10..00000000 --- a/website/templates/sign_up.html +++ /dev/null @@ -1,48 +0,0 @@ -{% extends "base.html" %} {% block title %}Sign Up{% endblock %} {% block -content %} -
-

Sign Up

-
- - -
-
- - -
-
- - -
-
- - -
-
- -
-{% endblock %} diff --git a/website/views.py b/website/views.py deleted file mode 100644 index d17a938e..00000000 --- a/website/views.py +++ /dev/null @@ -1,37 +0,0 @@ -from flask import Blueprint, render_template, request, flash, jsonify -from flask_login import login_required, current_user -from .models import Note -from . import db -import json - -views = Blueprint('views', __name__) - - -@views.route('/', methods=['GET', 'POST']) -@login_required -def home(): - if request.method == 'POST': - note = request.form.get('note')#Gets the note from the HTML - - if len(note) < 1: - flash('Note is too short!', category='error') - else: - new_note = Note(data=note, user_id=current_user.id) #providing the schema for the note - db.session.add(new_note) #adding the note to the database - db.session.commit() - flash('Note added!', category='success') - - return render_template("home.html", user=current_user) - - -@views.route('/delete-note', methods=['POST']) -def delete_note(): - note = json.loads(request.data) # this function expects a JSON from the INDEX.js file - noteId = note['noteId'] - note = Note.query.get(noteId) - if note: - if note.user_id == current_user.id: - db.session.delete(note) - db.session.commit() - - return jsonify({}) From ddda33c87e47df7cbd0b60f24a024e0959ab13b3 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 02:27:49 +0100 Subject: [PATCH 48/51] Delete main.py Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- main.py | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 main.py diff --git a/main.py b/main.py deleted file mode 100644 index 8d8790cd..00000000 --- a/main.py +++ /dev/null @@ -1,6 +0,0 @@ -from website import create_app - -app = create_app() -# test hh444 -if __name__ == '__main__': - app.run(debug=True) From 55a3fb55765271f880d2185bb60540662b422877 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 02:28:01 +0100 Subject: [PATCH 49/51] Delete requirements.txt Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- requirements.txt | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index b7a97419..00000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -flask -Flask-SQLAlchemy -flask-login \ No newline at end of file From bba70f8b1581e1b3bb809e0611c78130e0f40ca3 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 02:28:19 +0100 Subject: [PATCH 50/51] Delete .github/workflows directory Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- .github/workflows/deploy.yml | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index fe21a780..00000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: PR Deploy -on: - pull_request: - types: [opened, closed, synchronize, reopened] - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Deploy PR - uses: ./ - with: - server_host: ${{ secrets.SERVER_HOST }} - server_username: ${{ secrets.SERVER_USERNAME }} - server_password: ${{ secrets.SERVER_PASSWORD }} - server_port: ${{ secrets.SERVER_PORT }} - context: '.' - dockerfile: 'Dockerfile' - exposed_port: '5000' - github_token: ${{ secrets.GITHUB_TOKEN }} From 7a9804a5777d8b4d2f88df3c8d665a3703187687 Mon Sep 17 00:00:00 2001 From: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> Date: Thu, 1 Aug 2024 02:28:35 +0100 Subject: [PATCH 51/51] Delete Dockerfile Signed-off-by: Adesoji Awobajo <46819806+sodiadrhain@users.noreply.github.com> --- Dockerfile | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 4c5bf107..00000000 --- a/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM python:3.8-slim-buster - -WORKDIR /python-docker - -COPY requirements.txt requirements.txt -RUN pip3 install -r requirements.txt - -COPY . . - -EXPOSE 5000:5000 - -CMD [ "python3", "-m" , "flask", "--app", "main.py", "run", "--host=0.0.0.0", "--port=5000"]