main github actions #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: Deployment Dev | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
env_file: | |
description: 'Environment file to use (e.g., .env, .env_prod)' | |
required: true | |
default: '.env' | |
jobs: | |
build-and-deploy: | |
name: Build and Deployment | |
runs-on: ubuntu-20.04 | |
permissions: | |
packages: write | |
contents: read | |
attestations: write | |
steps: | |
# Deploy to Server | |
- name: SSH & Deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_SERVER_IP }} | |
username: ${{ secrets.SSH_SERVER_USER }} | |
key: ${{ secrets.FRONTEND_SSH_KEY }} | |
script: | | |
#!/usr/bin/env bash | |
cd nova-showcase | |
sudo git checkout main; | |
sudo git pull origin main; | |
sudo docker build -t autlabs/hub:main . --build-arg ENV_FILE=.env | |
# sudo docker push autlabs/hub:main | |
echo "Stopping and removing specific service: hub_main" | |
sudo docker-compose stop hub_main | |
sudo docker-compose rm -f hub_main | |
echo "Removing dangling images" | |
sudo docker rmi $(sudo docker images -f "dangling=true" -q) || true | |
echo "Pulling the new image" | |
# sudo docker-compose pull hub_main | |
docker-compose up -d --build hub_main | |
exit 0; |