-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9a9ed3
commit a01dbb9
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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 |