File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 285
285
# Get GHES release version in major.minor format
286
286
RELEASE_VERSION=$( ghe-ssh " $GHE_HOSTNAME " -- ' ghe-config --get core.package-version' | cut -d ' .' -f 1,2)
287
287
288
+ # If the backup being restored is from an appliance with Actions disabled, restoring it onto an appliance with Actions enabled will cause
289
+ # mismatches in the secrets needed for Actions which ultimately results in Actions not working properly. Note: xargs is to remove whitespace
290
+ ACTIONS_ENABLED_IN_BACKUP=$( git config -f $GHE_RESTORE_SNAPSHOT_PATH /settings.json --bool app.actions.enabled | xargs)
291
+ if [[ $ACTIONS_ENABLED_IN_BACKUP != true ]] && ghe-ssh " $GHE_HOSTNAME " -- ' ghe-config --true app.actions.enabled' ; then
292
+ echo " Error: Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2
293
+ exit 1
294
+ fi
295
+
288
296
# Make sure the GitHub appliance has Actions enabled if the snapshot contains Actions data.
289
297
# If above is true, also check if ac is present in appliance then snapshot should also contains ac databases
290
298
if [ -d " $GHE_RESTORE_SNAPSHOT_PATH /mssql" ] || [ -d " $GHE_RESTORE_SNAPSHOT_PATH /actions" ]; then
Original file line number Diff line number Diff line change 6
6
. " $( dirname " $0 " ) /testlib.sh"
7
7
8
8
setup_test_data " $GHE_DATA_DIR /1"
9
+ setup_actions_enabled_settings_for_restore true
9
10
10
11
# Make the current symlink
11
12
ln -s 1 " $GHE_DATA_DIR /current"
@@ -700,3 +701,17 @@ end_test
700
701
# verify_all_restored_data
701
702
# )
702
703
# end_test
704
+
705
+ begin_test " ghe-restore fails if Actions is disabled in the backup but enabled on the appliance"
706
+ (
707
+ set -e
708
+ rm -rf " $GHE_REMOTE_ROOT_DIR "
709
+ setup_remote_metadata
710
+ setup_actions_enabled_settings_for_restore false
711
+ enable_actions
712
+
713
+ setup_maintenance_mode " configured"
714
+
715
+ ! ghe-restore -v -f localhost
716
+ )
717
+ end_test
Original file line number Diff line number Diff line change @@ -594,3 +594,11 @@ cleanup_moreutils_parallel() {
594
594
unlink " $ROOTDIR /test/bin/parallel"
595
595
fi
596
596
}
597
+
598
+ # setup_actions_enabled_in_settings_json writes settings for the Actions app to settings.json
599
+ # it accepts true or false as first argument to enable or disable actions in settings.json
600
+ setup_actions_enabled_settings_for_restore () {
601
+ # Empty the file, it now contains "fake ghe-export-settings data"
602
+ echo > " $GHE_DATA_DIR /1/settings.json"
603
+ git config -f " $GHE_DATA_DIR /1/settings.json" --bool app.actions.enabled $1
604
+ }
You can’t perform that action at this time.
0 commit comments