Last active
June 6, 2024 10:37
-
-
Save zahidhassanshaikot/b613713804ac3d59ac15b91616b29e60 to your computer and use it in GitHub Desktop.
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
| --- | |
| 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" |
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
| workflow: | |
| rules: | |
| - if: $CI_COMMIT_BRANCH == 'main' | |
| when: always | |
| - when: never | |
| stages: | |
| - deploy-production | |
| stage-deploy-production: | |
| stage: deploy-production | |
| image: alpine | |
| script: | |
| # Connect to the server and run deploy script | |
| - apk add --update openssh | |
| - chmod 400 $NOBIN_KEY | |
| - ssh -i $NOBIN_KEY -o StrictHostKeyChecking=no -p $NOBIN_PORT $SSH_USER@$HOST "cd /home/laraveltheme/admin-nobin.laravel-theme.com/ && git pull origin main && composer install --optimize-autoloader --no-dev --no-interaction && yes | php artisan migrate && php artisan optimize:clear && exit" | |
| only: | |
| - main | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment