File tree 1 file changed +37
-0
lines changed
1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : CI/CD Pipeline
2
+
3
+ # Controls when the action will run. Triggers the workflow on push events but only for the main branch
4
+ on :
5
+ push :
6
+ branches :
7
+ - main # Change this to your deployment branch
8
+
9
+ # A workflow run is made up of one or more jobs that can run sequentially or in parallel
10
+ jobs :
11
+ deploy :
12
+ runs-on : ubuntu-latest
13
+
14
+ steps :
15
+ - name : Checkout code
16
+ uses : actions/checkout@v2
17
+
18
+ # Add additional steps here to install dependencies, run tests, etc.
19
+
20
+ - name : Deploy
21
+ env :
22
+ SSH_PRIVATE_KEY : ${{ secrets.SSH_PRIVATE_KEY }}
23
+ SSH_HOST : ${{ secrets.SSH_HOST }}
24
+ SSH_USER : ${{ secrets.SSH_USER }}
25
+ run : |
26
+ echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
27
+ mkdir -p ~/.ssh
28
+ touch ~/.ssh/known_hosts
29
+ ssh-keyscan $SSH_HOST >> ~/.ssh/known_hosts
30
+ ssh $SSH_USER@$SSH_HOST << 'EOF'
31
+ cd /path/to/your/application # Change this to your application's path on the server
32
+ git pull origin main # Ensure you're pulling the right branch, e.g., `main`
33
+ # Add commands to restart your service/application if necessary
34
+ # Example for Node.js with PM2:
35
+ npm install
36
+ pm2 restart app_name
37
+ EOF
You can’t perform that action at this time.
0 commit comments