Skip to content

fix code path

fix code path #2

Workflow file for this run

name: Build and Push Docker Image
on:
push:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Create .env file
run: |
echo "POSTGRES_USER=${{ secrets.POSTGRES_USER }}" > .env
echo "POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}" >> .env
echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" >> .env
echo "DATABASE_MIGRATION_URL=${{ secrets.DATABASE_MIGRATION_URL }}" >> .env
echo "PORT=${{ secrets.PORT }}" >> .env
echo "ENVIRONMENT=${{ secrets.ENVIRONMENT }}" >> .env
echo "REDIS_URL=${{ secrets.REDIS_URL }}" >> .env
echo "WHITELIST_DOMAIN=${{ secrets.WHITELIST_DOMAIN }}" >> .env
env:
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
DATABASE_MIGRATION_URL: ${{ secrets.DATABASE_MIGRATION_URL }}
PORT: ${{ secrets.PORT }}
ENVIRONMENT: ${{ secrets.ENVIRONMENT }}
REDIS_URL: ${{ secrets.REDIS_URL }}
WHITELIST_DOMAIN: ${{ secrets.WHITELIST_DOMAIN }}
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./server/Dockerfile # Specify the path to your Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
slackingdjaeger/jagadis-server:latest
slackingdjaeger/jagadis-server:${{ github.sha }}
- name: SSH to update .env, docker-compose.yml, and run migrations on the server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
mkdir -p jagadis
scp .env ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:jagadis/.env
scp ./server/docker-compose.yml ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:jagadis/docker-compose.yml
scp -r ./server/src/db ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:jagadis/db
ssh ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} "cd jagadis && docker-compose up -d && cd db && go run migrate.go"