adjusted prod yml #24
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: | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
username: autlabs | |
password: ${{ secrets.DOCKER_ACCESS_TOKEN }} | |
- name: Build and Push Docker Image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: Dockerfile | |
push: true | |
tags: autlabs/launchpad:main | |
build-args: | |
ENV_FILE=${{ github.event.inputs.env_file }} | |
# 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 | |
echo "Listing directory contents" | |
ls -l | |
cd aut-integrate | |
sudo git checkout main; | |
sudo git pull origin main; | |
echo "Stopping and removing specific service: aut_expander_main" | |
sudo docker-compose stop aut_expander_main | |
sudo docker-compose rm -f aut_expander_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 aut_expander_main | |
docker-compose up -d --build aut_expander_main | |
exit 0; |