Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ runs:
if: github.event.action != 'closed'
shell: bash
run: |
whoami
PR_ID="pr_${{ github.event.repository.id }}_${{ github.event.number }}"
cd "${{ inputs.context }}"
docker build -t $PR_ID -f "${{ inputs.dockerfile }}" .
docker save $PR_ID | gzip > "/tmp/${PR_ID}.tar.gz"
echo "${{ inputs.server_password }}" | sudo -S docker build -t $PR_ID -f "Dockerfile" .
echo "${{ inputs.server_password }}" | sudo -S docker save $PR_ID | gzip > "/tmp/${PR_ID}.tar.gz"
# sudo docker build -t $PR_ID -f "${{ inputs.dockerfile }}" .
# sudo docker save $PR_ID | gzip > "/tmp/${PR_ID}.tar.gz"
- id: execute-deployment
name: Execute deployment
run: |
Expand Down
6 changes: 3 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if [ -n "$SERVER_PRIVATE_KEY" ]; then
SSH_CMD="ssh -i private_key.pem -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST"

# Copy the script to the remote server.
scp -i private_key.pem -o StrictHostKeyChecking=no -P $SERVER_PORT pr-deploy.sh $SERVER_USERNAME@$SERVER_HOST:"/tmp/" >/dev/null
scp -i private_key.pem -o StrictHostKeyChecking=no -P $SERVER_PORT pr-deploy.sh $SERVER_USERNAME@$SERVER_HOST:pr-deploy.sh>/dev/null

# Check if PR_ACTION is not 'closed'
if [ "$PR_ACTION" != "closed" ]; then
Expand All @@ -30,7 +30,7 @@ else
SSH_CMD="sshpass -p $SERVER_PASSWORD ssh -o StrictHostKeyChecking=no -p $SERVER_PORT $SERVER_USERNAME@$SERVER_HOST"

# Copy the script to the remote server.
sshpass -p "$SERVER_PASSWORD" scp -o StrictHostKeyChecking=no -P $SERVER_PORT pr-deploy.sh $SERVER_USERNAME@$SERVER_HOST:"/tmp/" >/dev/null
sshpass -p "$SERVER_PASSWORD" scp -o StrictHostKeyChecking=no -P $SERVER_PORT pr-deploy.sh $SERVER_USERNAME@$SERVER_HOST:pr-deploy.sh>/dev/null


# Check if PR_ACTION is not 'closed'
Expand Down Expand Up @@ -59,7 +59,7 @@ $SSH_CMD \
HOST_VOLUME_PATH='$HOST_VOLUME_PATH' \
CONTAINER_VOLUME_PATH='$CONTAINER_VOLUME_PATH' \
COMMENT_ID='$COMMENT_ID' \
bash -c 'echo $SERVER_PASSWORD | sudo -SE bash \"/tmp/pr-deploy.sh\"'" | tee "/tmp/preview_${GITHUB_RUN_ID}.txt"
bash -c 'echo $SERVER_PASSWORD | sudo -SE bash \"pr-deploy.sh\"'" | tee "/tmp/preview_${GITHUB_RUN_ID}.txt"

PREVIEW_URL=$(tail -n 1 "/tmp/preview_${GITHUB_RUN_ID}.txt")
echo "preview-url=${PREVIEW_URL}" >> $GITHUB_OUTPUT