Merge branch 'main' of gitea.mikemcfetridge.com:miker/Docker-02
This commit is contained in:
+24
-38
@@ -1,48 +1,34 @@
|
||||
name: Validate and Deploy Homelab
|
||||
name: Deploy ArrStack
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'ArrStack/**' # <-- CRITICAL: Only triggers if files in the watchtower folder change
|
||||
|
||||
jobs:
|
||||
test-and-deploy:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository Code
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Verify Compose File Validity
|
||||
env:
|
||||
DB_ROOT_PASSWORD: ${{ secrets.MYSQL_ROOT_PASSWORD }}
|
||||
DB_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
|
||||
run: docker compose config
|
||||
- name: Sync ArrStack to Host
|
||||
uses: appleboy/scp-action@master
|
||||
with:
|
||||
host: "192.168.2.8"
|
||||
username: "miker"
|
||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
source: "ArrStack/"
|
||||
target: "/opt/Docker-Deployments"
|
||||
|
||||
# --- DEPLOYMENT PHASE ---
|
||||
|
||||
- name: Set up SSH Private Key
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/id_ed25519
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
# Scan the host key to prevent SSH hanging on a manual confirmation prompt
|
||||
ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Create Remote Docker Context
|
||||
run: |
|
||||
# Define a remote endpoint pointing to your live server over SSH
|
||||
docker context create homelab-target \
|
||||
--docker "host=ssh://${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}"
|
||||
|
||||
- name: Deploy Containers to Live Server
|
||||
env:
|
||||
# Pass your production secrets to the live deployment step
|
||||
DB_ROOT_PASSWORD: ${{ secrets.MYSQL_ROOT_PASSWORD }}
|
||||
DB_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
|
||||
run: |
|
||||
echo "Switching Docker context to live server..."
|
||||
docker context use homelab-target
|
||||
|
||||
echo "Pulling latest images and starting services remotely..."
|
||||
# The --project-directory . flag ensures it reads the docker-compose file fetched by Git
|
||||
docker compose --project-directory . up -d --remove-orphans
|
||||
- name: Deploy ArrStack Stack
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: "192.168.2.8"
|
||||
username: "miker"
|
||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
script: |
|
||||
cd /opt/Docker-Deployments/ArrStack
|
||||
docker compose up -d --remove-orphans
|
||||
Reference in New Issue
Block a user