Update deploy.yml #13
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 PyDay to VPS | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| name: Checkout código | |
| - uses: actions/setup-node@v4 | |
| name: Setup Node.js 22.x | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| - name: Creacion variables de entorno | |
| run: | | |
| touch .env.local | |
| echo "DB_USER=${{ secrets.NEXT_PUBLIC_FEATURE_REGISTRATION }}" >> .env.local | |
| echo "DB_PASS=${{ secrets.NEXT_PUBLIC_FEATURE_SPONSORS }}" >> .env.local | |
| echo "API_URL=${{ secrets.NEXT_PUBLIC_FEATURE_SPONSOR_FORM }}" >> .env.local | |
| echo "APP_SECRET=${{ secrets.NEXT_PUBLIC_SITE_URL }}" >> .env.local | |
| - name: Instalar dependencias y build | |
| run: | | |
| npm ci | |
| npm run build | |
| - name: Copia archivos hacia servidor | |
| uses: appleboy/scp-action@v1 | |
| with: | |
| host: ${{ secrets.PYDAY_SERVER }} | |
| username: ${{ secrets.PYDAY_USER }} | |
| password: ${{ secrets.PYDAY_PASS }} | |
| port: ${{ secrets.PYDAY_PORT }} | |
| source: ".next,public,next.config.mjs,package.json,package-lock.json,.env.local" | |
| target: "pydaydotcl" | |
| - name: Iniciar app con PM2 en el servidor | |
| uses: appleboy/ssh-action@v1 | |
| with: | |
| host: ${{ secrets.PYDAY_SERVER }} | |
| username: ${{ secrets.PYDAY_USER }} | |
| password: ${{ secrets.PYDAY_PASS }} | |
| port: ${{ secrets.PYDAY_PORT }} | |
| script: | | |
| cd pydaydotcl | |
| export NVM_DIR="$HOME/.nvm" | |
| source "$NVM_DIR/nvm.sh" | |
| nvm use 22 | |
| npm install --omit=dev | |
| pm2 delete pydaydotcl || true | |
| pm2 start npm --name "pydaydotcl" -- start |