Merge pull request #1 from CUT-Labs/development #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: Deploy FUNDNA to Jackson Server | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_ACCESS_TOKEN }} | |
- name: Build and push Docker image | |
id: push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: jphuse/fundna:latest | |
- name: Install SSH client | |
run: sudo apt-get install -y openssh-client | |
- name: Deploy Docker image to SSH server | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
password: ${{ secrets.SSH_PASSWORD }} | |
port: ${{ secrets.SSH_PORT }} | |
script: | | |
# Ensure cron is installed and running | |
if ! command -v cron &> /dev/null | |
then | |
sudo apt-get update | |
sudo apt-get install -y cron | |
fi | |
sudo service cron start | |
# Log into Docker on the SSH Server | |
docker login -u jphuse -p ${{ secrets.DOCKER_ACCESS_TOKEN }} | |
# Remove the container if it exists | |
docker rm -f fundna || true | |
# Pull the latest Docker image | |
docker pull jphuse/fundna:latest | |
# Run the Docker container with environment variables | |
docker run -d --name fundna \ | |
--network=jphuse_network \ | |
-e MYSQLHOST=${{ secrets.MYSQLHOST }} \ | |
-e MYSQLPORT=${{ secrets.MYSQLPORT }} \ | |
-e MYSQLUSER=${{ secrets.MYSQLUSER }} \ | |
-e MYSQLPASSWORD=${{ secrets.MYSQLPASSWORD }} \ | |
-e MYSQLDATABASE=${{ secrets.MYSQLDATABASE }} \ | |
-e DJANGO_SETTINGS_MODULE=${{ secrets.DJANGO_SETTINGS_MODULE }} \ | |
-e PYTHONUNBUFFERED=${{ secrets.PYTHONUNBUFFERED }} \ | |
-p 16458:16458 \ | |
jphuse/fundna:latest |