Deploy to Production #4
This file contains hidden or 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: Deploy to Production | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| - name: Merge test into main | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git merge origin/test | |
| git push origin main | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build site | |
| run: npm run build | |
| - name: Install lftp | |
| run: sudo apt-get install -y lftp | |
| - name: Deploy via SFTP | |
| timeout-minutes: 5 | |
| env: | |
| SFTP_USER: ${{ secrets.SFTP_USER }} | |
| SFTP_PASSWORD: ${{ secrets.SFTP_PASSWORD }} | |
| SFTP_HOST: ${{ secrets.SFTP_HOST }} | |
| run: | | |
| lftp <<EOF | |
| set sftp:auto-confirm yes | |
| set net:timeout 30 | |
| set net:max-retries 2 | |
| open -u "$SFTP_USER,$SFTP_PASSWORD" sftp://$SFTP_HOST | |
| mirror --reverse --delete --verbose ./dist/ /zooza.online/sub/docs/ | |
| quit | |
| EOF |