Skip to content

Commit

Permalink
modifications to workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
leoBitto committed Apr 1, 2024
1 parent 5d77ff9 commit 4bff673
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.DO_SSH_PRIVATE_KEY }}
key: ${{ secrets.PRIVATE_KEY }}
script: |
mkdir -p "/opt/${{ env.REPO_NAME }}"
mkdir -p "/opt/${{ env.REPO_NAME }}/config"
Expand All @@ -50,7 +50,7 @@ jobs:
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.DO_SSH_PRIVATE_KEY }}
key: ${{ secrets.PRIVATE_KEY }}
source: "./docker-compose-prod.yml"
target: "/opt/${{ env.REPO_NAME }}/"

Expand All @@ -59,7 +59,7 @@ jobs:
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.DO_SSH_PRIVATE_KEY }}
key: ${{ secrets.PRIVATE_KEY }}
source: "./nginx/nginx.conf"
target: "/opt/${{ env.REPO_NAME }}/"

Expand All @@ -68,7 +68,7 @@ jobs:
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.DO_SSH_PRIVATE_KEY }}
key: ${{ secrets.PRIVATE_KEY }}
script: |
sed -i "s/server_name localhost/server_name ${{ secrets.DOMAIN }}/g" /opt/${{ env.REPO_NAME }}/nginx/nginx.conf
Expand All @@ -77,7 +77,7 @@ jobs:
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.DO_SSH_PRIVATE_KEY }}
key: ${{ secrets.PRIVATE_KEY }}
script: |
sudo apt update -y
sudo apt upgrade -y
Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.DO_SSH_PRIVATE_KEY }}
key: ${{ secrets.PRIVATE_KEY }}
script: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
echo ${REGISTRY}/${OWNER_LC}/${{ env.IMAGE_NAME }}:latest
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ the actions read from the secrets of github, they contain the following informat

other info used by the droplet and the container registry:

1. **DO_SSH_PRIVATE_KEY**-> private key from server
1. **PRIVATE_KEY**-> private key from server
1. **GHCR_TOKEN** -> [token of github](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)
1. **HOST** -> droplet IP address
1. **USERNAME** -> root
Expand Down
20 changes: 10 additions & 10 deletions manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
# Questa funzione elimina le immagini precedenti e avvia i container
build_and_start_containers() {
# Elimina i container e i volumi esistenti (opzionale)
sudo docker-compose -f docker-compose-dev.yml down -v --remove-orphans
sudo docker-compose -f docker-compose.dev.yml down -v --remove-orphans

# Avvia i container Docker in background e ricrea le immagini se necessario
sudo docker-compose -f docker-compose-dev.yml up -d --build
sudo docker-compose -f docker-compose.dev.yml up -d --build
echo "Immagini create"

# Applica le migrazioni del database all'interno del container "web"
sudo docker-compose -f docker-compose-dev.yml exec web python manage.py migrate --noinput
sudo docker-compose -f docker-compose.dev.yml exec web python manage.py migrate --noinput
echo "Migrazioni eseguite"

# Raccoglie i file statici all'interno del container "web", cancellando quelli esistenti
sudo docker-compose -f docker-compose-dev.yml exec web python manage.py collectstatic --noinput --clear
sudo docker-compose -f docker-compose.dev.yml exec web python manage.py collectstatic --noinput --clear
echo "File statici raccolti"

# Crea un superuser con le credenziali dalle variabili d'ambiente
sudo docker-compose -f docker-compose-dev.yml exec web python manage.py createsuperuser
sudo docker-compose -f docker-compose.dev.yml exec web python manage.py createsuperuser

echo "Superuser creato"
echo "Server in esecuzione"
Expand All @@ -27,15 +27,15 @@ build_and_start_containers() {
# Questa funzione avvia solo i container Docker
start_containers() {
# Avvia i container Docker in background
sudo docker-compose -f docker-compose-dev.yml up -d
sudo docker-compose -f docker-compose.dev.yml up -d
echo "Immagini create"

# Applica le migrazioni del database all'interno del container "web"
sudo docker-compose -f docker-compose-dev.yml exec web python manage.py migrate --noinput
sudo docker-compose -f docker-compose.dev.yml exec web python manage.py migrate --noinput
echo "Migrazioni eseguite"

# Raccoglie i file statici all'interno del container "web", cancellando quelli esistenti
sudo docker-compose -f docker-compose-dev.yml exec web python manage.py collectstatic --noinput --clear
sudo docker-compose -f docker-compose.dev.yml exec web python manage.py collectstatic --noinput --clear
echo "File statici raccolti"

echo "Server in esecuzione"
Expand All @@ -44,15 +44,15 @@ start_containers() {
# Questa funzione ferma i container Docker
stop_containers() {
# Ferma tutti i container precedenti
sudo docker-compose -f docker-compose-dev.yml down
sudo docker-compose -f docker-compose.dev.yml down

echo "Server fermato"
}

# Questa funzione elimina tutti i container e i volumi
destroy_containers() {
# Elimina tutti i container e i volumi associati
sudo docker-compose -f docker-compose-dev.yml down -v --remove-orphans
sudo docker-compose -f docker-compose.dev.yml down -v --remove-orphans

echo "Container e volumi eliminati"
}
Expand Down

0 comments on commit 4bff673

Please sign in to comment.