Add LEGACY_NETWORK variable to environment files #13

Merged
kovagoadi merged 12 commits from legacy-network-restriction into main 2025-11-29 19:41:53 +01:00
Showing only changes of commit a57e44ca67 - Show all commits

View File

@@ -21,7 +21,7 @@ env:
jobs: jobs:
# ------------------------------------------------------------------ # ------------------------------------------------------------------
# STAGE 1: PREPARE # STAGE 1: PREPARE CONTEXT
# ------------------------------------------------------------------ # ------------------------------------------------------------------
prepare_context: prepare_context:
name: Prepare Context name: Prepare Context
@@ -42,31 +42,28 @@ jobs:
deploy_preview: deploy_preview:
name: Deploy (Dev/Preview) name: Deploy (Dev/Preview)
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: needs: [prepare_context]
- prepare_context
if: github.event_name == 'pull_request' && github.event.action != 'closed' if: github.event_name == 'pull_request' && github.event.action != 'closed'
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: webfactory/ssh-agent@v0.9.0 - name: Deploy via Rsync & Docker
with: uses: easingthemes/ssh-deploy@v5.0.0
ssh-private-key: ${{ env.SSH_PRIVATE_KEY }} env:
SSH_PRIVATE_KEY: ${{ env.SSH_PRIVATE_KEY }}
- name: Sync & Build REMOTE_HOST: ${{ env.SSH_HOST }}
run: | REMOTE_USER: ${{ env.SSH_USER }}
mkdir -p ~/.ssh && ssh-keyscan -p ${{ env.SSH_PORT }} ${{ env.SSH_HOST }} >> ~/.ssh/known_hosts REMOTE_PORT: ${{ env.SSH_PORT }}
TARGET="${{ needs.prepare_context.outputs.pr_path }}" TARGET: ${{ needs.prepare_context.outputs.pr_path }}
# Exclude git internals to save bandwidth
ssh -p ${{ env.SSH_PORT }} ${{ env.SSH_USER }}@${{ env.SSH_HOST }} "mkdir -p '$TARGET'" EXCLUDE: ".git/, .github/"
# 1. Create directory first
rsync -avz -e "ssh -p ${{ env.SSH_PORT }}" \ SCRIPT_BEFORE: |
--exclude '.git/' --exclude '.github/' \ mkdir -p ${{ needs.prepare_context.outputs.pr_path }}
./ ${{ env.SSH_USER }}@${{ env.SSH_HOST }}:$TARGET/ # 2. Run Docker Compose after sync
SCRIPT_AFTER: |
ssh -p ${{ env.SSH_PORT }} ${{ env.SSH_USER }}@${{ env.SSH_HOST }} " cd ${{ needs.prepare_context.outputs.pr_path }}
cd '$TARGET'
docker compose --env-file dev.env -f docker-compose.yaml up -d --build --remove-orphans docker compose --env-file dev.env -f docker-compose.yaml up -d --build --remove-orphans
"
# ------------------------------------------------------------------ # ------------------------------------------------------------------
# STAGE 3: DEPLOY STAGING # STAGE 3: DEPLOY STAGING
@@ -78,25 +75,20 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: webfactory/ssh-agent@v0.9.0 - name: Deploy via Rsync & Docker
with: uses: easingthemes/ssh-deploy@v5.0.0
ssh-private-key: ${{ env.SSH_PRIVATE_KEY }} env:
SSH_PRIVATE_KEY: ${{ env.SSH_PRIVATE_KEY }}
- name: Sync & Build REMOTE_HOST: ${{ env.SSH_HOST }}
run: | REMOTE_USER: ${{ env.SSH_USER }}
mkdir -p ~/.ssh && ssh-keyscan -p ${{ env.SSH_PORT }} ${{ env.SSH_HOST }} >> ~/.ssh/known_hosts REMOTE_PORT: ${{ env.SSH_PORT }}
TARGET="${{ env.REMOTE_STAGING_PATH }}" TARGET: ${{ env.REMOTE_STAGING_PATH }}
EXCLUDE: ".git/, .github/"
ssh -p ${{ env.SSH_PORT }} ${{ env.SSH_USER }}@${{ env.SSH_HOST }} "mkdir -p '$TARGET'" SCRIPT_BEFORE: |
mkdir -p ${{ env.REMOTE_STAGING_PATH }}
rsync -avz -e "ssh -p ${{ env.SSH_PORT }}" \ SCRIPT_AFTER: |
--exclude '.git/' --exclude '.github/' \ cd ${{ env.REMOTE_STAGING_PATH }}
./ ${{ env.SSH_USER }}@${{ env.SSH_HOST }}:$TARGET/
ssh -p ${{ env.SSH_PORT }} ${{ env.SSH_USER }}@${{ env.SSH_HOST }} "
cd '$TARGET'
docker compose --env-file staging.env -f docker-compose.yaml up -d --build --remove-orphans docker compose --env-file staging.env -f docker-compose.yaml up -d --build --remove-orphans
"
# ------------------------------------------------------------------ # ------------------------------------------------------------------
# STAGE 4: DEPLOY PRODUCTION # STAGE 4: DEPLOY PRODUCTION
@@ -104,59 +96,50 @@ jobs:
deploy_prod: deploy_prod:
name: Deploy (Production) name: Deploy (Production)
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: needs: [deploy_staging]
- deploy_staging
if: github.ref == 'refs/heads/main' if: github.ref == 'refs/heads/main'
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: webfactory/ssh-agent@v0.9.0 - name: Deploy via Rsync & Docker
with: uses: easingthemes/ssh-deploy@v5.0.0
ssh-private-key: ${{ env.SSH_PRIVATE_KEY }} env:
SSH_PRIVATE_KEY: ${{ env.SSH_PRIVATE_KEY }}
- name: Sync & Build REMOTE_HOST: ${{ env.SSH_HOST }}
run: | REMOTE_USER: ${{ env.SSH_USER }}
mkdir -p ~/.ssh && ssh-keyscan -p ${{ env.SSH_PORT }} ${{ env.SSH_HOST }} >> ~/.ssh/known_hosts REMOTE_PORT: ${{ env.SSH_PORT }}
TARGET="${{ env.REMOTE_PROD_PATH }}" TARGET: ${{ env.REMOTE_PROD_PATH }}
EXCLUDE: ".git/, .github/"
ssh -p ${{ env.SSH_PORT }} ${{ env.SSH_USER }}@${{ env.SSH_HOST }} "mkdir -p '$TARGET'" SCRIPT_BEFORE: |
mkdir -p ${{ env.REMOTE_PROD_PATH }}
rsync -avz -e "ssh -p ${{ env.SSH_PORT }}" \ SCRIPT_AFTER: |
--exclude '.git/' --exclude '.github/' \ cd ${{ env.REMOTE_PROD_PATH }}
./ ${{ env.SSH_USER }}@${{ env.SSH_HOST }}:$TARGET/
ssh -p ${{ env.SSH_PORT }} ${{ env.SSH_USER }}@${{ env.SSH_HOST }} "
cd '$TARGET'
docker compose --env-file prod.env -f docker-compose.yaml up -d --build --remove-orphans docker compose --env-file prod.env -f docker-compose.yaml up -d --build --remove-orphans
"
# ------------------------------------------------------------------ # ------------------------------------------------------------------
# CLEANUP # CLEANUP (Using appleboy/ssh-action for pure command execution)
# ------------------------------------------------------------------ # ------------------------------------------------------------------
cleanup: cleanup:
name: Cleanup Preview name: Cleanup Preview
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: needs: [prepare_context]
- prepare_context
if: github.event_name == 'pull_request' && (github.event.action == 'closed' || github.event.pull_request.merged == true) if: github.event_name == 'pull_request' && (github.event.action == 'closed' || github.event.pull_request.merged == true)
steps: steps:
- uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ env.SSH_PRIVATE_KEY }}
- name: Remove Remote Environment - name: Remove Remote Environment
run: | uses: appleboy/ssh-action@v1.0.3
mkdir -p ~/.ssh && ssh-keyscan -p ${{ env.SSH_PORT }} ${{ env.SSH_HOST }} >> ~/.ssh/known_hosts with:
host: ${{ env.SSH_HOST }}
username: ${{ env.SSH_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
port: ${{ env.SSH_PORT }}
script: |
TARGET="${{ needs.prepare_context.outputs.pr_path }}" TARGET="${{ needs.prepare_context.outputs.pr_path }}"
if [ -d "$TARGET" ]; then
ssh -p ${{ env.SSH_PORT }} ${{ env.SSH_USER }}@${{ env.SSH_HOST }} " cd "$TARGET"
if [ -d '$TARGET' ]; then
cd '$TARGET'
docker compose down -v || true docker compose down -v || true
cd .. cd ..
rm -rf '$TARGET' rm -rf "$TARGET"
echo 'Cleanup successful' echo "Cleanup successful"
else else
echo 'Directory not found, skipping.' echo "Directory not found, skipping."
fi fi
"