Skip to content

Commit

Permalink
cleanup webroot before copying files
Browse files Browse the repository at this point in the history
  • Loading branch information
rantanevich committed Mar 15, 2024
1 parent 43af90c commit 9ec2b15
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
22 changes: 8 additions & 14 deletions .github/actions/deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ inputs:
webroot:
description: The root directory of the web server that will be used to search for a file
required: true
temproot:
description: The temproot directory of the web server that will be used to search for a file
required: true
serv:
systemd_service:
description: Systemd service name
required: true
ssh_hostname:
Expand Down Expand Up @@ -64,24 +61,21 @@ runs:
- name: Build project
working-directory: ui
shell: sh
run: |
pnpm run build
rm -rf node_modules
run: pnpm run build

- name: Deploy compiled project to the remote server
shell: sh
run: |
set -x
sshpass -p "${{ inputs.ssh_password }}" \
rsync \
--archive \
--verbose \
--human-readable \
--delete-before \
${{ inputs.keep_source_maps == 'false' && '--exclude="*.map"' || '' }} ui/ ${{ inputs.ssh_username }}@${{ inputs.ssh_hostname }}:${{ inputs.webroot }}/
ssh ${{ inputs.ssh_username }}@${{ inputs.ssh_hostname }} rm -rf ${{ inputs.webroot }}/*
sshpass -p "${{ inputs.ssh_password }}" \
ssh ${{ inputs.ssh_username }}@${{ inputs.ssh_hostname }} "sudo systemctl restart ${{ inputs.serv }}"
scp -r ui/ ${{ inputs.ssh_username }}@${{ inputs.ssh_hostname }}:${{ inputs.webroot }}/
sshpass -p "${{ inputs.ssh_password }}" \
ssh ${{ inputs.ssh_username }}@${{ inputs.ssh_hostname }} "sudo systemctl restart ${{ inputs.systemd_service }}"
# - name: Copy Files to Server
# shell: sh
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
"ssh_password": "${{ secrets.FRONT_SCORE_SSH }}",
"lib_latest": "true",
"keep_source_maps": "false",
"serv": "names-test.service"
"systemd_service": "names-test.service"
},
"^main$": {
"node_env": "production",
Expand All @@ -58,7 +58,7 @@ jobs:
"ssh_password": "${{ secrets.FRONT_SCORE_SSH }}",
"lib_latest": "false",
"keep_source_maps": "false",
"serv": "names.service"
"systemd_service": "names.service"
}
}
export_to: output,log
Expand All @@ -69,7 +69,7 @@ jobs:
with:
webroot: ${{ steps.settings.outputs.webroot }}
temproot: ${{ steps.settings.outputs.temproot }}
serv: ${{ steps.settings.outputs.serv }}
systemd_service: ${{ steps.settings.outputs.systemd_service }}
ssh_hostname: ${{ steps.settings.outputs.ssh_hostname }}
ssh_username: ${{ secrets.SERVER_USERNAME }}
ssh_password: ${{ steps.settings.outputs.ssh_password }}
Expand Down

0 comments on commit 9ec2b15

Please sign in to comment.