-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add auto update from deployment via ssh (#359)
- Loading branch information
1 parent
7665a6d
commit 9bdc1ad
Showing
1 changed file
with
44 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,44 @@ | ||
name: Continuous Deployment via SSH | ||
on: | ||
[workflow_dispatch] | ||
# push: | ||
# branches: | ||
# - main | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [18.x, 20.x] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install SSH Key | ||
run: | | ||
mkdir -p ~/.ssh/ | ||
echo "${{ secrets.DEPLOYUSERSSHKEY }}" > ~/.ssh/id_rsa | ||
chmod 600 ~/.ssh/id_rsa | ||
- name: Execute Deployment Commands | ||
run: | | ||
ssh -o StrictHostKeyChecking=no [email protected] << 'EOF' | ||
source ~/.profile || true | ||
source ~/.bashrc || true | ||
# Ensure you're in the correct directory | ||
cd ~/belindasFrontEnd | ||
# Fetch the latest changes | ||
git pull origin main | ||
# Activate the Node.js version managed by nvm | ||
source ~/.nvm/nvm.sh | ||
nvm use ${{ matrix.node-version }} | ||
# Install any new dependencies using npm from nvm | ||
npm install | ||
# Build the project | ||
npm run build | ||
# Restart the application with PM2 | ||
pm2 restart belindas-frontend | ||
EOF |