more Fixes #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Deploy | |
on: | |
push: | |
branches: | |
- main # Change to your main branch name if different | |
jobs: | |
build: | |
runs-on: ubuntu-latest # We will continue to use a standard Ubuntu runner | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '18' # Specify your Node.js version | |
- name: Install dependencies | |
run: npm install | |
- name: Build project | |
run: npm run build # Replace with your actual build command | |
- name: Upload files via FTPES with recursive directory creation and curl | |
env: | |
FTPES_HOST: ${{ secrets.FTPES_HOST }} | |
FTPES_USERNAME: ${{ secrets.FTPES_USERNAME }} | |
FTPES_PASSWORD: ${{ secrets.FTPES_PASSWORD }} | |
run: | | |
# Traverse the build directory and handle recursive directory creation and file upload | |
find dist -type f | while read file; do | |
# Extract the directory part of the file path | |
dir=$(dirname "$file") | |
# Convert the local directory path to the FTP path | |
remote_dir="${dir#dist/}" | |
# Create the directory on the FTP server if it doesn't exist | |
curl --ssl-reqd --user $FTPES_USERNAME:$FTPES_PASSWORD -Q "MKD $remote_dir" ftp://$FTPES_HOST | |
# Upload the file to the correct remote directory | |
curl -T "$file" --ssl-reqd --user $FTPES_USERNAME:$FTPES_PASSWORD ftp://$FTPES_HOST/$remote_dir/$(basename "$file") | |
done | |