File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments