Compare commits
3 Commits
main
...
chore/depl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
690012ff1f | ||
|
|
2dec3cdaa1 | ||
|
|
81fcc4606f |
90
scripts/deploy.sh
Executable file
90
scripts/deploy.sh
Executable file
@ -0,0 +1,90 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Deploy Paper Dynasty Database API
|
||||||
|
# Usage: ./scripts/deploy.sh <dev|prod> [commit]
|
||||||
|
#
|
||||||
|
# Dev: Force-updates the "dev" git tag → CI builds :dev Docker image
|
||||||
|
# Prod: Creates CalVer tag + force-updates "latest" and "production" git tags
|
||||||
|
# → CI builds :<calver>, :latest, :production Docker images
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
NC='\033[0m'
|
||||||
|
|
||||||
|
REMOTE="origin"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 <dev|prod> [commit]"
|
||||||
|
echo ""
|
||||||
|
echo " dev [commit] Force-update 'dev' tag on HEAD or specified commit"
|
||||||
|
echo " prod [commit] Create CalVer + 'latest' + 'production' tags on HEAD or specified commit"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
[[ $# -lt 1 ]] && usage
|
||||||
|
|
||||||
|
ENV="$1"
|
||||||
|
COMMIT="${2:-HEAD}"
|
||||||
|
|
||||||
|
SHA=$(git rev-parse "$COMMIT" 2>/dev/null) || {
|
||||||
|
echo -e "${RED}Invalid commit: $COMMIT${NC}"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
SHA_SHORT="${SHA:0:7}"
|
||||||
|
|
||||||
|
git fetch --tags "$REMOTE"
|
||||||
|
|
||||||
|
if ! git branch -a --contains "$SHA" 2>/dev/null | grep -qE '(^|\s)(main|remotes/origin/main)$'; then
|
||||||
|
echo -e "${RED}Commit $SHA_SHORT is not on main. Aborting.${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$ENV" in
|
||||||
|
dev)
|
||||||
|
echo -e "${YELLOW}Deploying to dev...${NC}"
|
||||||
|
echo -e " Commit: ${SHA_SHORT}"
|
||||||
|
|
||||||
|
git tag -f dev "$SHA"
|
||||||
|
git push "$REMOTE" dev --force
|
||||||
|
|
||||||
|
echo -e "${GREEN}Tagged ${SHA_SHORT} as 'dev' and pushed. CI will build :dev image.${NC}"
|
||||||
|
;;
|
||||||
|
|
||||||
|
prod)
|
||||||
|
echo -e "${YELLOW}Deploying to prod...${NC}"
|
||||||
|
|
||||||
|
YEAR=$(date -u +%Y)
|
||||||
|
MONTH=$(date -u +%-m)
|
||||||
|
PREFIX="${YEAR}.${MONTH}."
|
||||||
|
|
||||||
|
LAST_BUILD=$(git tag -l "${PREFIX}*" | sed "s/^${PREFIX}//" | sort -n | tail -1)
|
||||||
|
BUILD=$((${LAST_BUILD:-0} + 1))
|
||||||
|
CALVER="${PREFIX}${BUILD}"
|
||||||
|
|
||||||
|
echo -e " Commit: ${SHA_SHORT}"
|
||||||
|
echo -e " Version: ${CALVER}"
|
||||||
|
echo -e " Tags: ${CALVER}, latest, production"
|
||||||
|
|
||||||
|
read -rp "Proceed? [y/N] " confirm
|
||||||
|
[[ "$confirm" =~ ^[Yy]$ ]] || {
|
||||||
|
echo "Aborted."
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
git tag "$CALVER" "$SHA"
|
||||||
|
git tag -f latest "$SHA"
|
||||||
|
git tag -f production "$SHA"
|
||||||
|
|
||||||
|
git push "$REMOTE" "$CALVER"
|
||||||
|
git push "$REMOTE" latest --force
|
||||||
|
git push "$REMOTE" production --force
|
||||||
|
|
||||||
|
echo -e "${GREEN}Tagged ${SHA_SHORT} as '${CALVER}', 'latest', 'production' and pushed.${NC}"
|
||||||
|
echo -e "${GREEN}CI will build :${CALVER}, :latest, :production images.${NC}"
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
esac
|
||||||
@ -2,9 +2,6 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
{% include 'style.html' %}
|
{% include 'style.html' %}
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;700&family=Source+Sans+3:wght@400;700&display=swap" rel="stylesheet">
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="fullCard" style="width: 1200px; height: 600px;">
|
<div id="fullCard" style="width: 1200px; height: 600px;">
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user