Skip to content

Instantly share code, notes, and snippets.

@Robiussani152
Last active February 7, 2024 08:18
Show Gist options
  • Save Robiussani152/79fa67b2a9105627715a9c816ab67a61 to your computer and use it in GitHub Desktop.
Save Robiussani152/79fa67b2a9105627715a9c816ab67a61 to your computer and use it in GitHub Desktop.
Gitlab CI/CD pipeline yml file
---
image: alpine:latest
stages:
- deploy
stage-deploy:
stage: deploy
environment:
name: staging
url: http://example.com
when: manual
before_script:
- 'command -v ssh-agent >/dev/null || ( apk add --update openssh )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan -p $PORT $HOST >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- ssh -p $PORT $SSH_USER@$HOST "cd /deployed_path && git pull && more-commands"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment