Skip to content

Commit

Permalink
Update deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
BaseMax authored Sep 4, 2024
1 parent 3b71d55 commit a9a59c6
Showing 1 changed file with 12 additions and 41 deletions.
53 changes: 12 additions & 41 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,26 @@
on: [push]

jobs:
mirror_with_sftp:
name: deploy
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Clear Remote Directory

- name: Install Dependencies
run: npm install --force

- name: Build Project
run: npm run build

- name: Upload dist Files to SFTP
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: 22
script: |
rm -rf ${{ secrets.SERVER_PATH }}*
- name: FTP Deployer
uses: sand4rt/[email protected]
with:
sftp: true
host: ${{ secrets.SERVER_HOST }}
port: ${{ secrets.SERVER_PORT }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
remote_folder: ${{ secrets.SERVER_PATH }}
local_folder: '.'
cleanup: false
include: '[ "*", "**/*" ]'
exclude: '["node_modules/**", ".github/**", ".git/**", "*.env"]'
pasive: true

- name: Check if the directory is empty
id: check_dir
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: 22
script: |
if [ -z "$(ls -A ${{ secrets.SERVER_PATH }})" ]; then
echo "DIRECTORY_EMPTY=true" >> $GITHUB_ENV
else
echo "DIRECTORY_EMPTY=false" >> $GITHUB_ENV
fi
- name: Run additional commands if the directory is not empty
if: env.DIRECTORY_EMPTY == 'false'
run: |
npm install
npm run build
rm -rf ${{ secrets.SERVER_PATH }}*
mkdir -p ${{ secrets.SERVER_PATH }}/dist
scp -r ./dist/* ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_HOST }}:${{ secrets.SERVER_PATH }}/dist

0 comments on commit a9a59c6

Please sign in to comment.