fix: improve GitHub Actions workflow with debugging and testing #5
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: Build and Deploy Static Export | |
| on: | |
| push: | |
| tags: | |
| - 'v*' # Triggers on any tag starting with 'v' (e.g., v1.0.0, v1.2.3) | |
| pull_request: | |
| branches: [main] # Build PRs for testing, but don't deploy | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' # Updated to match project's Node version requirements | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Build static export | |
| run: npm run build # This will run next build which generates the 'out' directory | |
| - name: Verify build output | |
| run: | | |
| echo "Checking if build succeeded..." | |
| ls -la out/ | |
| echo "Build output files:" | |
| find out/ -type f | head -10 | |
| - name: Test - Check deployment configuration (PR only) | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| echo "🧪 Testing deployment configuration..." | |
| echo "Event: ${{ github.event_name }}" | |
| echo "Ref: ${{ github.ref }}" | |
| echo "Would deploy on tag creation: ${{ startsWith(github.ref, 'refs/tags/v') }}" | |
| echo "FTP_HOST is set: ${{ secrets.FTP_HOST != '' }}" | |
| echo "FTP_USERNAME is set: ${{ secrets.FTP_USERNAME != '' }}" | |
| echo "FTP_PASSWORD is set: ${{ secrets.FTP_PASSWORD != '' }}" | |
| echo "Local directory exists: $([ -d './out/' ] && echo 'Yes' || echo 'No')" | |
| if [ -d './out/' ]; then | |
| echo "Files to deploy: $(find ./out/ -type f | wc -l)" | |
| echo "Directory size: $(du -sh ./out/)" | |
| fi | |
| - name: Deploy to FTP (Production) | |
| if: github.event_name == 'pull_request' | |
| uses: SamKirkland/FTP-Deploy-Action@4.3.0 | |
| with: | |
| server: ${{ secrets.FTP_HOST }} | |
| username: ${{ secrets.FTP_USERNAME }} | |
| password: ${{ secrets.FTP_PASSWORD }} | |
| local-dir: ./out/ | |
| server-dir: /www/new | |
| exclude: | | |
| **/.git* | |
| **/.git*/** | |
| **/node_modules/** | |
| **/.DS_Store | |
| dry-run: false | |