adjusted prod yml #33
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 Prod | |
on: | |
push: | |
branches: | |
- mainnet | |
workflow_dispatch: | |
inputs: | |
env_file: | |
description: 'Environment file to use (e.g., .env, .env_prod)' | |
required: true | |
default: '.env_prod' | |
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:mainnet | |
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 mainnet; | |
sudo git pull origin mainnet; | |
echo "Stopping and removing specific service: aut_expander_mainnet" | |
sudo docker-compose stop aut_expander_mainnet | |
sudo docker-compose rm -f aut_expander_mainnet | |
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_mainnet | |
docker-compose up -d --build aut_expander_mainnet | |
exit 0; |