Skip to content

Commit c66629b

Browse files
authored
Merge pull request #69 from hngprojects/dev
Dev Update: Added functionality to enable/disable comments feature
2 parents c2642e2 + 35c1390 commit c66629b

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ inputs:
3535
github_token:
3636
description: GitHub token to authenticate API requests
3737
required: true
38+
comment:
39+
description: A boolean value stating if the comments feature should be provided
40+
required: false
41+
default: false
3842

3943
outputs:
4044
preview-url:
@@ -65,6 +69,7 @@ runs:
6569
DOCKERFILE: ${{ inputs.dockerfile }}
6670
EXPOSED_PORT: ${{ inputs.exposed_port }}
6771
ENVS: ${{ inputs.envs }}
72+
COMMENT: ${{ inputs.comment }}
6873
REPO_URL: ${{ github.event.repository.clone_url }}
6974
REPO_OWNER: ${{ github.repository_owner }}
7075
REPO_NAME: ${{ github.event.repository.name }}

entrypoint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $S
1414
DOCKERFILE='$DOCKERFILE' \
1515
EXPOSED_PORT='$EXPOSED_PORT' \
1616
ENVS='$ENVS' \
17+
COMMENT='$COMMENT' \
1718
REPO_OWNER='$REPO_OWNER' \
1819
REPO_NAME='$REPO_NAME' \
1920
REPO_URL='$REPO_URL' \

pr-deploy.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ PID_FILE="/srv/pr-deploy/nohup.json"
88
COMMENT_ID_FILE="/srv/pr-deploy/comments.json"
99

1010
comment() {
11+
# Check if comments are enabled
12+
if [ "$COMMENT" != true ]; then
13+
return
14+
fi
15+
1116
local status_message=$1
1217
echo $status_message
1318

@@ -72,14 +77,16 @@ if [ ! -f "$PID_FILE" ]; then
7277
echo {} > $PID_FILE
7378
fi
7479

75-
# Initialize the JSON file for comment if it doesn't exist
76-
if [ ! -f "$COMMENT_ID_FILE" ]; then
80+
# Initialize the JSON file for comment if comments are enabled and it doesn't exist
81+
if [ "$COMMENT" == true ] && [ ! -f "$COMMENT_ID_FILE" ]; then
7782
echo {} > $COMMENT_ID_FILE
7883
fi
7984

80-
# Handle COMMENT_ID
81-
COMMENT_ID=$(jq -r --arg key $PR_ID '.[$key] // ""' ${COMMENT_ID_FILE})
82-
comment "Deploying ⏳"
85+
# Handle COMMENT_ID if only comments are enabled
86+
if [ "$COMMENT" == true ]; then
87+
COMMENT_ID=$(jq -r --arg key $PR_ID '.[$key] // ""' ${COMMENT_ID_FILE})
88+
comment "Deploying ⏳"
89+
fi
8390

8491
# Ensure docker is installed
8592
if [ ! command -v docker &> /dev/null ]; then

0 commit comments

Comments
 (0)