70 lines
2.0 KiB
YAML
70 lines
2.0 KiB
YAML
name: Build & Deployment
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "main"
|
|
|
|
env:
|
|
REMOTE_WORKING_DIRECTORY: compose/wedding-website
|
|
|
|
jobs:
|
|
build:
|
|
name: Build & Deploy
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
path: repository
|
|
|
|
- name: Copy Repository over SSH
|
|
uses: garygrossgarten/github-action-scp@release
|
|
with:
|
|
local: repository
|
|
remote: ${{ env.REMOTE_WORKING_DIRECTORY }}
|
|
host: ${{ secrets.SSH_HOST }}
|
|
username: ${{ secrets.SSH_USERNAME }}
|
|
privateKey: ${{ secrets.SSH_KEY }}
|
|
rmRemote: true
|
|
|
|
- name: Build ENV
|
|
run: |
|
|
echo "${{ secrets.WEDDING_WEBSITE_ENV }}" | base64 -d > .env
|
|
|
|
- name: Copy ENV over SSH
|
|
uses: garygrossgarten/github-action-scp@release
|
|
with:
|
|
local: .env
|
|
remote: ${{ env.REMOTE_WORKING_DIRECTORY }}/.env
|
|
host: ${{ secrets.SSH_HOST }}
|
|
username: ${{ secrets.SSH_USERNAME }}
|
|
privateKey: ${{ secrets.SSH_KEY }}
|
|
|
|
- name: Docker Compose Commands
|
|
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 }}
|
|
docker compose build
|
|
docker compose up -d wedding-db wedding-minio wedding-minio-init
|
|
docker compose up --force-recreate --no-deps --abort-on-container-exit --exit-code-from wedding-migrate wedding-migrate
|
|
docker compose up -d wedding-app
|
|
docker compose images
|
|
docker image prune --all --force
|
|
|
|
- name: Clean .env
|
|
if: always()
|
|
uses: appleboy/ssh-action@v1.0.3
|
|
with:
|
|
host: ${{ secrets.SSH_HOST }}
|
|
username: ${{ secrets.SSH_USERNAME }}
|
|
key: ${{ secrets.SSH_KEY }}
|
|
script: |
|
|
cd ${{ env.REMOTE_WORKING_DIRECTORY }}
|
|
rm -f .env
|