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
with:
ssh-private-key: ${{ env.SSH_PRIVATE_KEY }}
- name: Sync & Build - name: Deploy via Rsync & Docker
run: | uses: easingthemes/ssh-deploy@v5.0.0
mkdir -p ~/.ssh && ssh-keyscan -p ${{ env.SSH_PORT }} ${{ env.SSH_HOST }} >> ~/.ssh/known_hosts env:
TARGET="${{ needs.prepare_context.outputs.pr_path }}" SSH_PRIVATE_KEY: ${{ env.SSH_PRIVATE_KEY }}
REMOTE_HOST: ${{ env.SSH_HOST }}
ssh -p ${{ env.SSH_PORT }} ${{ env.SSH_USER }}@${{ env.SSH_HOST }} "mkdir -p '$TARGET'" REMOTE_USER: ${{ env.SSH_USER }}
REMOTE_PORT: ${{ env.SSH_PORT }}
rsync -avz -e "ssh -p ${{ env.SSH_PORT }}" \ TARGET: ${{ needs.prepare_context.outputs.pr_path }}
--exclude '.git/' --exclude '.github/' \ # Exclude git internals to save bandwidth
./ ${{ env.SSH_USER }}@${{ env.SSH_HOST }}:$TARGET/ EXCLUDE: ".git/, .github/"
# 1. Create directory first
ssh -p ${{ env.SSH_PORT }} ${{ env.SSH_USER }}@${{ env.SSH_HOST }} " SCRIPT_BEFORE: |
cd '$TARGET' mkdir -p ${{ needs.prepare_context.outputs.pr_path }}
# 2. Run Docker Compose after sync
SCRIPT_AFTER: |
cd ${{ needs.prepare_context.outputs.pr_path }}
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
@@ -77,26 +74,21 @@ jobs:
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
with:
ssh-private-key: ${{ env.SSH_PRIVATE_KEY }}
- name: Sync & Build - name: Deploy via Rsync & Docker
run: | uses: easingthemes/ssh-deploy@v5.0.0
mkdir -p ~/.ssh && ssh-keyscan -p ${{ env.SSH_PORT }} ${{ env.SSH_HOST }} >> ~/.ssh/known_hosts env:
TARGET="${{ env.REMOTE_STAGING_PATH }}" SSH_PRIVATE_KEY: ${{ env.SSH_PRIVATE_KEY }}
REMOTE_HOST: ${{ env.SSH_HOST }}
ssh -p ${{ env.SSH_PORT }} ${{ env.SSH_USER }}@${{ env.SSH_HOST }} "mkdir -p '$TARGET'" REMOTE_USER: ${{ env.SSH_USER }}
REMOTE_PORT: ${{ env.SSH_PORT }}
rsync -avz -e "ssh -p ${{ env.SSH_PORT }}" \ TARGET: ${{ env.REMOTE_STAGING_PATH }}
--exclude '.git/' --exclude '.github/' \ EXCLUDE: ".git/, .github/"
./ ${{ env.SSH_USER }}@${{ env.SSH_HOST }}:$TARGET/ SCRIPT_BEFORE: |
mkdir -p ${{ env.REMOTE_STAGING_PATH }}
ssh -p ${{ env.SSH_PORT }} ${{ env.SSH_USER }}@${{ env.SSH_HOST }} " SCRIPT_AFTER: |
cd '$TARGET' cd ${{ env.REMOTE_STAGING_PATH }}
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
with:
ssh-private-key: ${{ env.SSH_PRIVATE_KEY }}
- name: Sync & Build - name: Deploy via Rsync & Docker
run: | uses: easingthemes/ssh-deploy@v5.0.0
mkdir -p ~/.ssh && ssh-keyscan -p ${{ env.SSH_PORT }} ${{ env.SSH_HOST }} >> ~/.ssh/known_hosts env:
TARGET="${{ env.REMOTE_PROD_PATH }}" SSH_PRIVATE_KEY: ${{ env.SSH_PRIVATE_KEY }}
REMOTE_HOST: ${{ env.SSH_HOST }}
ssh -p ${{ env.SSH_PORT }} ${{ env.SSH_USER }}@${{ env.SSH_HOST }} "mkdir -p '$TARGET'" REMOTE_USER: ${{ env.SSH_USER }}
REMOTE_PORT: ${{ env.SSH_PORT }}
rsync -avz -e "ssh -p ${{ env.SSH_PORT }}" \ TARGET: ${{ env.REMOTE_PROD_PATH }}
--exclude '.git/' --exclude '.github/' \ EXCLUDE: ".git/, .github/"
./ ${{ env.SSH_USER }}@${{ env.SSH_HOST }}:$TARGET/ SCRIPT_BEFORE: |
mkdir -p ${{ env.REMOTE_PROD_PATH }}
ssh -p ${{ env.SSH_PORT }} ${{ env.SSH_USER }}@${{ env.SSH_HOST }} " SCRIPT_AFTER: |
cd '$TARGET' cd ${{ env.REMOTE_PROD_PATH }}
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:
TARGET="${{ needs.prepare_context.outputs.pr_path }}" host: ${{ env.SSH_HOST }}
username: ${{ env.SSH_USER }}
ssh -p ${{ env.SSH_PORT }} ${{ env.SSH_USER }}@${{ env.SSH_HOST }} " key: ${{ env.SSH_PRIVATE_KEY }}
if [ -d '$TARGET' ]; then port: ${{ env.SSH_PORT }}
cd '$TARGET' script: |
TARGET="${{ needs.prepare_context.outputs.pr_path }}"
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
"