Sample bitbucket pipeline for deploy to Linux
-
File: bitbucket-pipelines.yml
image: node:20 pipelines: branches: main: - step: name: Deploy to Linux script: - ssh [email protected] "cd /var/www && git pull && npm i && npm run build && pm2 restart 1"
Need to copy Bitbucket's id_rsa key to server's authorised_keys.
- Go to Repository Settings (of the particular repo)
- Pipeline > SSH Keys
Generate key.
Copy the generated key to authorised_keys in target server.
- Get the server's fingerprint, so Bitbucket can keep it. - enter the server IP, and click "Fetch"