-
Notifications
You must be signed in to change notification settings - Fork 1
/
reset-demo
executable file
·93 lines (80 loc) · 4.25 KB
/
reset-demo
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
#
# This script resets the DF24 Developer Tools demo workspace by doing the following:
# 1. Resets the demo to the starting commit.
# 2. Pushes the new commit state to the remote repository.
# 3. Returns to the main branch.
# 4. Deploys original versions of Apex classes.
#
# Exit on any error
set -e
branchName=WI-000002
tagName=DemoStart
demoDir=/home/codebuilder/df24-devtools-demo
taskName="DF24 DevTools Demo Reset"
# Ensure the script is being run from inside the demo directory.
if [ "$(pwd)" != "$demoDir" ]; then
echo -e "\u274C"" Error: Current directory is not $demoDir"
exit 1
fi
# Handle script errors.
function handle_error {
echo
echo -e "\u274C"" $taskName Failed"
echo
}
# Handle script success.
function handle_success {
echo
echo "───────────────────────────────────────────────────────────────────────"
echo
echo -e "\u2705"" $taskName Complete"
echo
echo "───────────────────────────────────────────────────────────────────────"
echo
}
# Send trapped errors to the error handler.
trap handle_error ERR
# Announce that the demo reset process has started.
echo
echo "───────────────────────────────────────────────────────────────────────"
echo
echo -e "\U1F680"" Starting $taskName"
# Reset the demo to the starting commit.
echo
echo "───────────────────────────────────────────────────────────────────────"
echo "(1) Resetting to the demo to the starting commit."
echo "───────────────────────────────────────────────────────────────────────"
echo
git reset --hard $tagName
# Disable the ERR trap and allow script errors
# This is requied in case the reset script is run when
# the local repo does not have the WI-000002 branch.
trap - ERR
set +e
# Push the new commit state to the remote repository.
echo
echo "───────────────────────────────────────────────────────────────────────"
echo "(2) Pushing the new commit state to the remote repository."
echo "───────────────────────────────────────────────────────────────────────"
echo
git push origin $branchName --force
# Enable the ERR trap and disallow script errors.
set -e
trap handle_error ERR
# Return to the main branch.
echo
echo "───────────────────────────────────────────────────────────────────────"
echo "(3) Returning to the main branch."
echo "───────────────────────────────────────────────────────────────────────"
echo
git checkout main
# Deploy original versions of Apex classes.
echo
echo "───────────────────────────────────────────────────────────────────────"
echo "(4) Deploying original versions of Apex classes."
echo "───────────────────────────────────────────────────────────────────────"
echo
sf project deploy start --source-dir force-app/main/default/classes --ignore-conflicts --concise
# Script completed successfully.
handle_success