File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed
Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff 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
3943outputs :
4044 preview-url :
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 }}
Original file line number Diff line number Diff 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 ' \
Original file line number Diff line number Diff line change @@ -8,6 +8,11 @@ PID_FILE="/srv/pr-deploy/nohup.json"
88COMMENT_ID_FILE=" /srv/pr-deploy/comments.json"
99
1010comment () {
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
7378fi
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
7883fi
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
8592if [ ! command -v docker & > /dev/null ]; then
You can’t perform that action at this time.
0 commit comments