Skip to content

Commit

Permalink
set workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
codinghack30 committed Aug 28, 2024
1 parent d9a9ed3 commit a01dbb9
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI/CD Pipeline

# Controls when the action will run. Triggers the workflow on push events but only for the main branch
on:
push:
branches:
- main # Change this to your deployment branch

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

# Add additional steps here to install dependencies, run tests, etc.

- name: Deploy
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_USER: ${{ secrets.SSH_USER }}
run: |
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
mkdir -p ~/.ssh
touch ~/.ssh/known_hosts
ssh-keyscan $SSH_HOST >> ~/.ssh/known_hosts
ssh $SSH_USER@$SSH_HOST << 'EOF'
cd /path/to/your/application # Change this to your application's path on the server
git pull origin main # Ensure you're pulling the right branch, e.g., `main`
# Add commands to restart your service/application if necessary
# Example for Node.js with PM2:
npm install
pm2 restart app_name
EOF

0 comments on commit a01dbb9

Please sign in to comment.