fix: adapt workflow better to local mounted volumes
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
name: Build & Deployment
|
||||
name: Deploy On Server
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -9,8 +9,8 @@ env:
|
||||
REMOTE_WORKING_DIRECTORY: compose/wedding-website
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build & Deploy
|
||||
prepare-repository-remotely:
|
||||
name: Prepare Repository Remotely
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
@@ -18,32 +18,72 @@ jobs:
|
||||
with:
|
||||
path: repository
|
||||
|
||||
- name: Copy Repository over SSH
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
- name: Prepare Remote Directory
|
||||
uses: appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: ${{ secrets.SSH_HOST }}
|
||||
username: ${{ secrets.SSH_USERNAME }}
|
||||
key: ${{ secrets.SSH_KEY }}
|
||||
source: "repository"
|
||||
script_stop: true
|
||||
script: |
|
||||
mkdir -p ${{ env.REMOTE_WORKING_DIRECTORY }}
|
||||
cd ${{ env.REMOTE_WORKING_DIRECTORY }}
|
||||
find . -mindepth 1 -maxdepth 1 \
|
||||
! -name wedding-db-data \
|
||||
! -name wedding-minio-data \
|
||||
-exec rm -rf {} +
|
||||
|
||||
- name: Copy Repository over SSH
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
with:
|
||||
host: ${{ secrets.SSH_HOST }}
|
||||
port: 22
|
||||
username: ${{ secrets.SSH_USERNAME }}
|
||||
key: ${{ secrets.SSH_KEY }}
|
||||
source: "repository/*"
|
||||
target: ${{ env.REMOTE_WORKING_DIRECTORY }}
|
||||
rm: false
|
||||
strip_components: 1
|
||||
rm: true
|
||||
|
||||
- name: Build ENV
|
||||
run: |
|
||||
echo "${{ secrets.WEDDING_WEBSITE_ENV }}" | base64 -d > .env
|
||||
mkdir env
|
||||
echo "${{ secrets.WEDDING_WEBSITE_ENV }}" | base64 -d > env/.env
|
||||
|
||||
- name: Copy ENV over SSH
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
with:
|
||||
host: ${{ secrets.SSH_HOST }}
|
||||
port: 22
|
||||
username: ${{ secrets.SSH_USERNAME }}
|
||||
key: ${{ secrets.SSH_KEY }}
|
||||
source: ".env"
|
||||
source: "env/.env"
|
||||
target: ${{ env.REMOTE_WORKING_DIRECTORY }}
|
||||
overwrite: true
|
||||
rm: false
|
||||
strip_components: 1
|
||||
|
||||
- name: Docker Compose Commands
|
||||
start-services:
|
||||
name: Docker Compose Up
|
||||
runs-on: ubuntu-latest
|
||||
needs: prepare-repository-remotely
|
||||
steps:
|
||||
- name: Start Services
|
||||
uses: appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: ${{ secrets.SSH_HOST }}
|
||||
username: ${{ secrets.SSH_USERNAME }}
|
||||
key: ${{ secrets.SSH_KEY }}
|
||||
script_stop: false
|
||||
script: |
|
||||
cd ${{ env.REMOTE_WORKING_DIRECTORY }}
|
||||
docker compose up --build -d
|
||||
|
||||
prune-images:
|
||||
name: Prune Images
|
||||
runs-on: ubuntu-latest
|
||||
needs: start-services
|
||||
steps:
|
||||
- name: Prune All Images
|
||||
uses: appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: ${{ secrets.SSH_HOST }}
|
||||
@@ -52,19 +92,21 @@ jobs:
|
||||
script_stop: true
|
||||
script: |
|
||||
cd ${{ env.REMOTE_WORKING_DIRECTORY }}
|
||||
docker compose build
|
||||
docker compose up -d wedding-db wedding-minio wedding-minio-init
|
||||
docker compose up -d wedding-app
|
||||
docker compose images
|
||||
docker image prune --all --force
|
||||
|
||||
- name: Clean .env
|
||||
if: always()
|
||||
remove-env-file:
|
||||
name: Remove .env File
|
||||
needs: start-services
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Execute rm .env
|
||||
uses: appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: ${{ secrets.SSH_HOST }}
|
||||
username: ${{ secrets.SSH_USERNAME }}
|
||||
key: ${{ secrets.SSH_KEY }}
|
||||
script_stop: true
|
||||
script: |
|
||||
cd ${{ env.REMOTE_WORKING_DIRECTORY }}
|
||||
rm -f .env
|
||||
rm .env
|
||||
|
||||
Reference in New Issue
Block a user