01.Setup Server #1
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
name: Setup Server | |
on: | |
workflow_dispatch: # Lanciato manualmente | |
jobs: | |
setup-server: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Connettersi al server via SSH e aggiornare il sistema | |
- name: Update server and install Docker & Nginx | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.PRIVATE_KEY }} | |
script: | | |
# Aggiornamento del server | |
sudo apt update -y | |
sudo apt upgrade -y | |
# Installazione di Docker | |
sudo apt-get install ca-certificates curl gnupg lsb-release -y | |
sudo mkdir -p /etc/apt/keyrings | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo tee /etc/apt/keyrings/docker.gpg > /dev/null | |
echo \ | |
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ | |
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
sudo apt-get update | |
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y | |
# Installazione di Nginx | |
sudo apt install nginx -y | |
# Abilitare i servizi | |
sudo systemctl enable docker | |
sudo systemctl enable nginx | |
# Step 2: Verifica dell'installazione | |
- name: Verify Docker and Nginx installation | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.PRIVATE_KEY }} | |
script: | | |
# Verifica Docker | |
docker --version | |
# Verifica Nginx | |
nginx -v |