initialising for ci-cd pipeline
CI/CD - ERP Core / scripts (pull_request) Failing after 12m21s
CI/CD - ERP Core / e2e-typecheck (pull_request) Failing after 13m13s
CI/CD - ERP Core / frontend (pull_request) Failing after 14m5s
CI/CD - ERP Core / backend (pull_request) Failing after 14m57s
CI/CD - ERP Core / detect (pull_request) Failing after 13m42s
CI/CD - ERP Core / Build & Deploy (pull_request) Failing after 12m47s
CI/CD - ERP Core / ci-ok (pull_request) Failing after 14m58s
CI/CD - ERP Core / scripts (pull_request) Failing after 12m21s
CI/CD - ERP Core / e2e-typecheck (pull_request) Failing after 13m13s
CI/CD - ERP Core / frontend (pull_request) Failing after 14m5s
CI/CD - ERP Core / backend (pull_request) Failing after 14m57s
CI/CD - ERP Core / detect (pull_request) Failing after 13m42s
CI/CD - ERP Core / Build & Deploy (pull_request) Failing after 12m47s
CI/CD - ERP Core / ci-ok (pull_request) Failing after 14m58s
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
# deploy.yml › detect — decide what this push deploys.
|
||||
#
|
||||
# A side deploys when its folder's tree hash differs from the hash last deployed SUCCESSFULLY to
|
||||
# this environment (stored on the server in /opt/erpcore/<env>/.deployed). So:
|
||||
# • docs / PROGRESS.md / smoke-script pushes deploy nothing,
|
||||
# • a failed deploy is retried by the next run (its stored hash never moved),
|
||||
# • force-pushes, multi-commit pushes and merges need no special handling.
|
||||
# Manual runs can force a side (config change) or pin an older hash (rollback).
|
||||
# shellcheck source=common.sh
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/common.sh"
|
||||
|
||||
: "${REF_NAME:?REF_NAME (the pushed branch) is required}"
|
||||
env_name="$(env_for_branch "$REF_NAME")" ||
|
||||
fail "branch '$REF_NAME' is not deployable (Dev → test, production → release)"
|
||||
load_env "$env_name"
|
||||
|
||||
be_hash="$(tree_hash "$BACKEND_PATH")"
|
||||
fe_hash="$(tree_hash "$FRONTEND_PATH")"
|
||||
mig_hash="$(tree_hash "$MIGRATIONS_PATH")"
|
||||
[[ -n "$be_hash" && -n "$fe_hash" ]] || fail "could not compute tree hashes — is this an ERP-core checkout?"
|
||||
|
||||
be_rollback=false
|
||||
fe_rollback=false
|
||||
if [[ -n "${BACKEND_HASH_INPUT:-}" ]]; then be_hash="$BACKEND_HASH_INPUT" && be_rollback=true; fi
|
||||
if [[ -n "${FRONTEND_HASH_INPUT:-}" ]]; then fe_hash="$FRONTEND_HASH_INPUT" && fe_rollback=true; fi
|
||||
|
||||
be_deployed="$(read_state backend)"
|
||||
fe_deployed="$(read_state frontend)"
|
||||
be_changed=false
|
||||
fe_changed=false
|
||||
if [[ "$be_hash" != "$be_deployed" ]]; then be_changed=true; fi
|
||||
if [[ "$fe_hash" != "$fe_deployed" ]]; then fe_changed=true; fi
|
||||
|
||||
deploy_backend=$be_changed
|
||||
deploy_frontend=$fe_changed
|
||||
if [[ "${FORCE_BACKEND:-}" == true ]]; then deploy_backend=true; fi
|
||||
if [[ "${FORCE_FRONTEND:-}" == true ]]; then deploy_frontend=true; fi
|
||||
|
||||
migrations_changed=false
|
||||
if ! $be_rollback && [[ "$mig_hash" != "$(read_state migrations)" ]]; then migrations_changed=true; fi
|
||||
|
||||
# A Gitea release records real content changes on release only — not forced restarts or
|
||||
# rollbacks (those are in .deployed/history.log on the server).
|
||||
record_release=false
|
||||
if [[ "$env_name" == release ]] && ! $be_rollback && ! $fe_rollback && { $be_changed || $fe_changed; }; then
|
||||
record_release=true
|
||||
fi
|
||||
|
||||
log "environment $env_name — deployed now: backend ${be_deployed:-none}, frontend ${fe_deployed:-none}"
|
||||
set_output env "$env_name"
|
||||
set_output backend "$deploy_backend"
|
||||
set_output frontend "$deploy_frontend"
|
||||
set_output backend_hash "$be_hash"
|
||||
set_output frontend_hash "$fe_hash"
|
||||
set_output backend_rollback "$be_rollback"
|
||||
set_output frontend_rollback "$fe_rollback"
|
||||
set_output migrations_hash "$mig_hash"
|
||||
set_output migrations_changed "$migrations_changed"
|
||||
set_output record_release "$record_release"
|
||||
Reference in New Issue
Block a user