Initial commit #1
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 VPS | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| check-secrets: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| has-vps-host: ${{ steps.check-vps.outputs.defined }} | |
| steps: | |
| - id: check-vps | |
| env: | |
| VPS_HOST: ${{ secrets.VPS_HOST }} | |
| if: "${{ env.VPS_HOST != '' }}" | |
| run: echo "defined=true" >> $GITHUB_OUTPUT | |
| - name: VPS secrets not set | |
| if: "${{ steps.check-vps.outputs.defined != 'true' }}" | |
| run: echo "VPS secret variables are not set. Skipping deployment." | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: [check-secrets] | |
| if: needs.check-secrets.outputs.has-vps-host == 'true' | |
| steps: | |
| - name: Deploy to VPS | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.VPS_HOST }} | |
| username: ${{ secrets.VPS_USERNAME }} | |
| key: ${{ secrets.VPS_SSH_KEY }} | |
| script: | | |
| set -e | |
| export NVM_DIR="$HOME/.nvm" | |
| [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | |
| export PATH="$HOME/.local/share/pnpm:$PATH" | |
| cd ~/genji-passkey | |
| git pull origin main | |
| pnpm install --frozen-lockfile | |
| pnpm build | |
| pm2 restart w3pk | |
| pm2 save |