Merge pull request #20 from pepijnolivier/main #23
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 Mingle-General Demo | |
on: | |
push: | |
branches: | |
- main | |
env: | |
space: 'mingle-demo' | |
image: 'mingle-demo' | |
default-commit-message: 'Deploying Mingle-General Demo' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Prepare SSH connections for deployment | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.DEPLOY_PVT_KEY }}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan -p 22 ${{ secrets.DEPLOY_SERVER }} >> ~/.ssh/known_hosts | |
- name: Set up environment | |
run: | | |
echo "SHA_SHORT=$(git rev-parse --short $GITHUB_SHA)" >> $GITHUB_ENV | |
- name: Build and push the Docker image | |
run: | | |
docker build . --file docker/production/Dockerfile --tag ${{ env.image }}:$SHA_SHORT | |
echo "Pushing image to the server..." | |
docker save ${{ env.image }}:$SHA_SHORT | ssh \ | |
${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_SERVER }} \ | |
'docker load' | |
ssh ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_SERVER }} ''' | |
mkdir -p ~/spaces/${{ env.space }} | |
cd ~/spaces/${{ env.space }} | |
mkdir -p storage/app storage/logs | |
''' | |
scp docker/production/docker-compose.production.yml \ | |
${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_SERVER }}:spaces/${{ env.space }}/docker-compose.yml | |
ssh ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_SERVER }} ''' | |
docker tag ${{ env.image }}:${{ env.SHA_SHORT }} ${{ env.image }}:latest | |
cd ~/spaces/${{ env.space }} | |
docker compose up -d --remove-orphans | |
''' |