Skip to content

Commit 3e21159

Browse files
authored
Create rasp.yml
1 parent aa0274f commit 3e21159

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.github/workflows/rasp.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Setup Raspberry Pi with Node.js and MongoDB
2+
3+
on:
4+
push:
5+
branches:
6+
- main # Run when code is pushed to the main branch
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v2
15+
16+
- name: Set up SSH key
17+
uses: webfactory/[email protected]
18+
with:
19+
ssh-private-key: ${{ secrets.PI_SSH_KEY }}
20+
21+
- name: Connect and setup Raspberry Pi
22+
env:
23+
PI_USER: ${{ secrets.PI_USER }}
24+
PI_HOST: ${{ secrets.PI_HOST }}
25+
run: |
26+
# Install Node.js and MongoDB on the Raspberry Pi
27+
ssh -o StrictHostKeyChecking=no $PI_USER@$PI_HOST << 'EOF'
28+
# Update the system
29+
sudo apt-get update && sudo apt-get upgrade -y
30+
31+
# Install Node.js (LTS version)
32+
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
33+
sudo apt-get install -y nodejs
34+
35+
# Verify Node.js and npm installation
36+
node -v
37+
npm -v
38+
39+
# Install MongoDB
40+
sudo apt-get install -y mongodb
41+
42+
# Start MongoDB and enable it to start on boot
43+
sudo systemctl start mongodb
44+
sudo systemctl enable mongodb
45+
46+
# Confirm MongoDB installation
47+
mongo --version
48+
49+
echo "Node.js and MongoDB installation complete on Raspberry Pi!"
50+
EOF

0 commit comments

Comments
 (0)