forked from BLC/sgeUpdated
31 lines
885 B
YAML
31 lines
885 B
YAML
name: sgeUpdated CI/CD
|
|
|
|
on:
|
|
pull_request:
|
|
types:
|
|
- opened # When a new PR is created
|
|
- closed # When a PR is merged or manually closed
|
|
branches:
|
|
- main # The target branch of the PR
|
|
|
|
jobs:
|
|
deploy:
|
|
if: github.event.pull_request.merged == true || github.event.action == 'opened'
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Setup SSH
|
|
run: |
|
|
mkdir -p ~/.ssh/
|
|
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
|
|
chmod 600 ~/.ssh/id_rsa
|
|
ssh-keyscan ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts
|
|
|
|
- name: Run deploy script on server
|
|
run: |
|
|
ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} << 'EOF'
|
|
echo "✅ PR event detected — running deploy script..."
|
|
cd /home/ubuntu/Bgreen/sgeUpdated
|
|
./deploy.sh
|
|
EOF
|