All checks were successful
Remote Deployment Pipeline / Prepare Context (push) Successful in 2s
Remote Deployment Pipeline / Deploy (Staging) (push) Successful in 45s
Remote Deployment Pipeline / Deploy (Dev/Preview) (push) Has been skipped
Remote Deployment Pipeline / Cleanup Preview (push) Has been skipped
Remote Deployment Pipeline / Deploy (Production) (push) Successful in 44s
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [easingthemes/ssh-deploy](https://github.com/easingthemes/ssh-deploy) | action | minor | `v5.0.0` -> `v5.1.1` | --- ### Release Notes <details> <summary>easingthemes/ssh-deploy (easingthemes/ssh-deploy)</summary> ### [`v5.1.1`](https://github.com/easingthemes/ssh-deploy/compare/v5.1.0...v5.1.1) [Compare Source](https://github.com/easingthemes/ssh-deploy/compare/v5.1.0...v5.1.1) ### [`v5.1.0`](https://github.com/easingthemes/ssh-deploy/releases/tag/v5.1.0) [Compare Source](https://github.com/easingthemes/ssh-deploy/compare/v5.0.3...v5.1.0) ##### What's Changed - Feature: Delete Script After Execution by [@​Armadillidiid](https://github.com/Armadillidiid) in [#​184](https://github.com/easingthemes/ssh-deploy/pull/184) ##### New Contributors - [@​Armadillidiid](https://github.com/Armadillidiid) made their first contribution in [#​184](https://github.com/easingthemes/ssh-deploy/pull/184) **Full Changelog**: <https://github.com/easingthemes/ssh-deploy/compare/v5.0.3...v5.1.0> ### [`v5.0.3`](https://github.com/easingthemes/ssh-deploy/releases/tag/v5.0.3) [Compare Source](https://github.com/easingthemes/ssh-deploy/compare/v5.0.2...v5.0.3) ##### What's Changed - Update actions to Node.js 20 by [@​alekw](https://github.com/alekw) in [#​180](https://github.com/easingthemes/ssh-deploy/pull/180) ##### New Contributors - [@​alekw](https://github.com/alekw) made their first contribution in [#​180](https://github.com/easingthemes/ssh-deploy/pull/180) **Full Changelog**: <https://github.com/easingthemes/ssh-deploy/compare/v5.0.2...v5.0.3> ### [`v5.0.2`](https://github.com/easingthemes/ssh-deploy/releases/tag/v5.0.2) [Compare Source](https://github.com/easingthemes/ssh-deploy/compare/v5.0.1...v5.0.2) ##### What's Changed - fix: added the missing declarations [#​177](https://github.com/easingthemes/ssh-deploy/issues/177) by [@​skyArony](https://github.com/skyArony) in [#​178](https://github.com/easingthemes/ssh-deploy/pull/178) ##### New Contributors - [@​skyArony](https://github.com/skyArony) made their first contribution in [#​178](https://github.com/easingthemes/ssh-deploy/pull/178) **Full Changelog**: <https://github.com/easingthemes/ssh-deploy/compare/v5.0.1...v5.0.2> ### [`v5.0.1`](https://github.com/easingthemes/ssh-deploy/compare/v5.0.0...v5.0.1) [Compare Source](https://github.com/easingthemes/ssh-deploy/compare/v5.0.0...v5.0.1) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi4yNi4xMSIsInVwZGF0ZWRJblZlciI6IjQyLjI2LjExIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Co-authored-by: kovagoadi <kovagoadi@kovagoadi.hu> Reviewed-on: https://gitea.kovagoadi.hu/kovagoadi.hu/traefik/pulls/17 Co-authored-by: Renovate Bot <renovate@kovagoadi.hu> Co-committed-by: Renovate Bot <renovate@kovagoadi.hu>
149 lines
5.6 KiB
YAML
149 lines
5.6 KiB
YAML
name: Remote Deployment Pipeline
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
types: [opened, synchronize, reopened, closed]
|
|
|
|
env:
|
|
# --- PATH CONFIGURATION ---
|
|
REMOTE_DEPLOY_PATH: /var/app/traefik/test
|
|
REMOTE_PROD_PATH: /var/app/traefik/prod
|
|
REMOTE_STAGING_PATH: /var/app/traefik/staging
|
|
|
|
# --- SECRETS ---
|
|
SSH_HOST: ${{ secrets.SSH_HOST }}
|
|
SSH_USER: ${{ secrets.SSH_USER }}
|
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
SSH_PORT: ${{ secrets.SSH_PORT || 22 }}
|
|
|
|
jobs:
|
|
# ------------------------------------------------------------------
|
|
# STAGE 1: PREPARE CONTEXT
|
|
# ------------------------------------------------------------------
|
|
prepare_context:
|
|
name: Prepare Context
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
pr_path: ${{ steps.calc.outputs.pr_path }}
|
|
steps:
|
|
- id: calc
|
|
name: Prepare Context
|
|
run: |
|
|
REPO_NAME=$(echo "${{ github.repository }}" | cut -d '/' -f 2)
|
|
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
|
echo "pr_path=${REMOTE_DEPLOY_PATH}/${REPO_NAME}-pr-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# ------------------------------------------------------------------
|
|
# STAGE 2: DEPLOY PREVIEW (DEV)
|
|
# ------------------------------------------------------------------
|
|
deploy_preview:
|
|
name: Deploy (Dev/Preview)
|
|
runs-on: ubuntu-latest
|
|
needs: [prepare_context]
|
|
if: github.event_name == 'pull_request' && github.event.action != 'closed'
|
|
steps:
|
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
|
|
|
- name: Deploy via Rsync & Docker
|
|
uses: easingthemes/ssh-deploy@a1aa0b6cf96ce2406eef90faa35007a4a7bf0ac0 # v5.1.1
|
|
env:
|
|
SSH_PRIVATE_KEY: ${{ env.SSH_PRIVATE_KEY }}
|
|
REMOTE_HOST: ${{ env.SSH_HOST }}
|
|
REMOTE_USER: ${{ env.SSH_USER }}
|
|
REMOTE_PORT: ${{ env.SSH_PORT }}
|
|
TARGET: ${{ needs.prepare_context.outputs.pr_path }}
|
|
# Exclude git internals to save bandwidth
|
|
EXCLUDE: ".git/, .github/"
|
|
# 1. Create directory first
|
|
SCRIPT_BEFORE: |
|
|
mkdir -p ${{ needs.prepare_context.outputs.pr_path }}
|
|
# 2. Run Docker Compose after sync
|
|
SCRIPT_AFTER: |
|
|
set -e
|
|
cd ${{ needs.prepare_context.outputs.pr_path }}
|
|
docker compose --env-file dev.env -f docker-compose.yaml up -d --build --remove-orphans
|
|
|
|
# ------------------------------------------------------------------
|
|
# STAGE 3: DEPLOY STAGING
|
|
# ------------------------------------------------------------------
|
|
deploy_staging:
|
|
name: Deploy (Staging)
|
|
runs-on: ubuntu-latest
|
|
if: github.ref == 'refs/heads/main'
|
|
steps:
|
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
|
|
|
- name: Deploy via Rsync & Docker
|
|
uses: easingthemes/ssh-deploy@a1aa0b6cf96ce2406eef90faa35007a4a7bf0ac0 # v5.1.1
|
|
env:
|
|
SSH_PRIVATE_KEY: ${{ env.SSH_PRIVATE_KEY }}
|
|
REMOTE_HOST: ${{ env.SSH_HOST }}
|
|
REMOTE_USER: ${{ env.SSH_USER }}
|
|
REMOTE_PORT: ${{ env.SSH_PORT }}
|
|
TARGET: ${{ env.REMOTE_STAGING_PATH }}
|
|
EXCLUDE: ".git/, .github/"
|
|
SCRIPT_BEFORE: |
|
|
mkdir -p ${{ env.REMOTE_STAGING_PATH }}
|
|
SCRIPT_AFTER: |
|
|
set -e
|
|
cd ${{ env.REMOTE_STAGING_PATH }}
|
|
docker compose --env-file staging.env -f docker-compose.yaml up -d --build --remove-orphans
|
|
|
|
# ------------------------------------------------------------------
|
|
# STAGE 4: DEPLOY PRODUCTION
|
|
# ------------------------------------------------------------------
|
|
deploy_prod:
|
|
name: Deploy (Production)
|
|
runs-on: ubuntu-latest
|
|
needs: [deploy_staging]
|
|
if: github.ref == 'refs/heads/main'
|
|
steps:
|
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
|
|
|
- name: Deploy via Rsync & Docker
|
|
uses: easingthemes/ssh-deploy@a1aa0b6cf96ce2406eef90faa35007a4a7bf0ac0 # v5.1.1
|
|
env:
|
|
SSH_PRIVATE_KEY: ${{ env.SSH_PRIVATE_KEY }}
|
|
REMOTE_HOST: ${{ env.SSH_HOST }}
|
|
REMOTE_USER: ${{ env.SSH_USER }}
|
|
REMOTE_PORT: ${{ env.SSH_PORT }}
|
|
TARGET: ${{ env.REMOTE_PROD_PATH }}
|
|
EXCLUDE: ".git/, .github/"
|
|
SCRIPT_BEFORE: |
|
|
mkdir -p ${{ env.REMOTE_PROD_PATH }}
|
|
SCRIPT_AFTER: |
|
|
set -e
|
|
cd ${{ env.REMOTE_PROD_PATH }}
|
|
docker compose --env-file prod.env -f docker-compose.yaml -f docker-compose.prod.yaml up -d --build --remove-orphans
|
|
|
|
# ------------------------------------------------------------------
|
|
# CLEANUP (Using appleboy/ssh-action for pure command execution)
|
|
# ------------------------------------------------------------------
|
|
cleanup:
|
|
name: Cleanup Preview
|
|
runs-on: ubuntu-latest
|
|
needs: [prepare_context]
|
|
if: github.event_name == 'pull_request' && (github.event.action == 'closed' || github.event.pull_request.merged == true)
|
|
steps:
|
|
- name: Remove Remote Environment
|
|
uses: appleboy/ssh-action@823bd89e131d8d508129f9443cad5855e9ba96f0 # v1.2.4
|
|
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 }}"
|
|
if [ -d "$TARGET" ]; then
|
|
cd "$TARGET"
|
|
docker compose down -v || true
|
|
cd ..
|
|
rm -rf "$TARGET"
|
|
echo "Cleanup successful"
|
|
else
|
|
echo "Directory not found, skipping."
|
|
fi |