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:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "main" ]
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'ArrStack/**' # <-- CRITICAL: Only triggers if files in the watchtower folder change
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-and-deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Verify Compose File Validity
|
- name: Sync ArrStack to Host
|
||||||
env:
|
uses: appleboy/scp-action@master
|
||||||
DB_ROOT_PASSWORD: ${{ secrets.MYSQL_ROOT_PASSWORD }}
|
with:
|
||||||
DB_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
|
host: "192.168.2.8"
|
||||||
run: docker compose config
|
username: "miker"
|
||||||
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
|
source: "ArrStack/"
|
||||||
|
target: "/opt/Docker-Deployments"
|
||||||
|
|
||||||
# --- DEPLOYMENT PHASE ---
|
- name: Deploy ArrStack Stack
|
||||||
|
uses: appleboy/ssh-action@master
|
||||||
- name: Set up SSH Private Key
|
with:
|
||||||
run: |
|
host: "192.168.2.8"
|
||||||
mkdir -p ~/.ssh
|
username: "miker"
|
||||||
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/id_ed25519
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
chmod 600 ~/.ssh/id_ed25519
|
script: |
|
||||||
# Scan the host key to prevent SSH hanging on a manual confirmation prompt
|
cd /opt/Docker-Deployments/ArrStack
|
||||||
ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts
|
docker compose up -d --remove-orphans
|
||||||
|
|
||||||
- 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
|
|
||||||
Reference in New Issue
Block a user