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

This commit is contained in:
2026-09-16 11:53:55 +05:30
parent 666979cf22
commit 8e472ac996
48 changed files with 2224 additions and 62 deletions
+59
View File
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
# deploy.yml › release — record a successful release deploy as a Gitea release + tag
# (release-YYYY.MM.DD-N on the deployed commit), including the tree hashes to roll back to.
# shellcheck source=common.sh
source "$(dirname "${BASH_SOURCE[0]}")/common.sh"
: "${GITHUB_SHA:?}" "${ERP_GIT_TOKEN:?}" "${BACKEND_HASH:?}" "${FRONTEND_HASH:?}"
command -v python3 >/dev/null 2>&1 || fail "python3 is required to build the release JSON"
load_env release
# side_result <job result> <reused> — human-readable outcome for the notes table.
side_result() {
case "$1" in
success) if [[ "$2" == true ]]; then echo "deployed (build reused)"; else echo "deployed (built)"; fi ;;
skipped) echo "unchanged" ;;
*) echo "$1" ;;
esac
}
today="$(TZ=Asia/Colombo date +%Y.%m.%d)"
mapfile -t tags < <(git_remote ls-remote --tags --refs "$REPO_GIT_URL" 'release-*' |
awk '{ sub("refs/tags/", "", $2); print $2 }' | sort -V)
previous="${tags[${#tags[@]}-1]:-}"
same_day=0
for t in "${tags[@]}"; do [[ "$t" == "release-$today-"* ]] && same_day=$((same_day + 1)); done
tag="release-$today-$((same_day + 1))"
# Pull requests since the previous release: fetch only the history after that tag.
if [[ -n "$previous" ]]; then
git_remote fetch -q --shallow-exclude="$previous" "$REPO_GIT_URL" "+refs/heads/production:refs/remotes/origin/production" ||
git_remote fetch -q --deepen=200 "$REPO_GIT_URL" "+refs/heads/production:refs/remotes/origin/production" || true
else
git_remote fetch -q --deepen=200 "$REPO_GIT_URL" "+refs/heads/production:refs/remotes/origin/production" || true
fi
prs="$(git log --merges --format='- %s' "$GITHUB_SHA" 2>/dev/null | grep -i ' into Dev' || true)"
body="Deployed to **release** ($PUBLIC_URL) from \`${GITHUB_SHA:0:12}\`.
| Side | Result | Tree hash — rollback input |
|---|---|---|
| Backend | $(side_result "${BACKEND_RESULT:-}" "${BACKEND_REUSED:-}") | \`$BACKEND_HASH\` |
| Frontend | $(side_result "${FRONTEND_RESULT:-}" "${FRONTEND_REUSED:-}") | \`$FRONTEND_HASH\` |
| Migrations | $([[ "${MIGRATIONS_CHANGED:-}" == true ]] && echo "changed (backup taken)" || echo "unchanged") | \`${MIGRATIONS_HASH:-}\` |
### Pull requests since ${previous:-the beginning}
${prs:-_(none found)_}
Rollback: Actions → **Deploy** → Run workflow on \`production\` with \`backend_hash\` / \`frontend_hash\` from a previous release (docs/40-DEPLOYMENT.md §9)."
payload="$(TAG="$tag" SHA="$GITHUB_SHA" BODY="$body" python3 -c '
import json, os
print(json.dumps({"tag_name": os.environ["TAG"], "target_commitish": os.environ["SHA"],
"name": os.environ["TAG"], "body": os.environ["BODY"]}))')"
log "creating Gitea release $tag"
curl -sS --fail-with-body -o /dev/null -X POST \
-H "Authorization: token $ERP_GIT_TOKEN" -H "Content-Type: application/json" \
--data "$payload" "$GITEA_URL/api/v1/repos/$REPO_SLUG/releases"
log "✅ $GITEA_URL/$REPO_SLUG/releases/tag/$tag"