-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrun_using_fly.sh
More file actions
executable file
·48 lines (40 loc) · 1.04 KB
/
run_using_fly.sh
File metadata and controls
executable file
·48 lines (40 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env bash
set -euo pipefail
# Default app name
APP_NAME=""
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--app)
APP_NAME="$2"
shift 2
;;
*)
shift
;;
esac
done
# Read the version from the VERSION file
VERSION=$(cat VERSION)
# Get the short commit hash of the current branch
COMMIT=$(git rev-parse --short HEAD)
# Get the current branch name
BRANCH=$(git rev-parse --abbrev-ref HEAD)
# Check if there are uncommitted changes
if [[ -n $(git status --porcelain) ]]; then
DIRTY=" (dirty)"
else
DIRTY=""
fi
# Construct the version string
if [[ "$BRANCH" == "master" || "$BRANCH" == "main" ]]; then
FULL_VERSION="${VERSION}${DIRTY}"
else
FULL_VERSION="${VERSION}@${BRANCH}${DIRTY}"
fi
# Run the deploy command with the constructed version
if [[ -n "$APP_NAME" ]]; then
fly deploy --app "$APP_NAME" --env VERSION="$FULL_VERSION" --env COMMIT="$COMMIT"
else
fly deploy --env VERSION="$FULL_VERSION" --env COMMIT="$COMMIT"
fi