Last active
August 1, 2025 06:43
-
-
Save serverok/2e72b47ed556e4cf751984e288d9d398 to your computer and use it in GitHub Desktop.
GitHub Actions Deploy Next.js to SFTP
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 Next.js to SFTP | |
| on: | |
| push: | |
| branches: | |
| - main # Or the branch you want to trigger the deployment on | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Create .env file | |
| run: | | |
| echo "NEXT_PUBLIC_API_URL=https://api.serverok.in/" > .env | |
| echo "NEXT_PUBLIC_APP_URL=https://serverok.in/" >> .env | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Build project | |
| run: npm run build | |
| - name: Deploy to SFTP server with SCP | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.SERVER_IP }} | |
| username: ${{ secrets.SERVER_USER }} | |
| port: ${{ secrets.SERVER_PORT }} | |
| key: ${{ secrets.SERVER_KEY }} | |
| strip_components: 1 | |
| source: "out/*" | |
| target: "/home/serverok/public_html/" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need the following secret setup for this to work
SERVER_KEY is the private key, the public key should be in .ssh/authorized_keys on the server