Skip to content

Commit bf329c6

Browse files
Merge pull request #316 from github/solmaz/medium-restore
[PERF] Provide version and size input for restore
2 parents 2817290 + c24d605 commit bf329c6

File tree

1 file changed

+38
-4
lines changed

1 file changed

+38
-4
lines changed

.github/workflows/restore.yml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,28 @@ on:
1919
required: false
2020
type: string
2121
default: 'master'
22+
version:
23+
description: 'Version of the dataset to restore (3.8/3.9)'
24+
required: false
25+
default: '3.8'
26+
type: string
2227

2328
workflow_call:
2429
inputs:
2530
hostname:
2631
description: 'Hostname of the server'
2732
required: true
2833
type: string
34+
size:
35+
description: 'Size of the dataset to restore (small/medium)'
36+
required: false
37+
default: 'small'
38+
type: string
39+
version:
40+
description: 'Version of the dataset to restore (3.8/3.9)'
41+
required: false
42+
default: '3.8'
43+
type: string
2944
ref:
3045
description: 'Branch ref to use'
3146
required: false
@@ -63,22 +78,41 @@ jobs:
6378
- name: Load docker container
6479
run: docker load -i backup-utils.tar
6580

81+
- name: Find backup file version
82+
id: file
83+
run: |
84+
version="${{ inputs.version }}"
85+
size="${{ inputs.size }}"
86+
V3_8_COMPATIBLE="3.6 3.7 3.8 3.9 3.10"
87+
echo "$V3_8_COMPATIBLE" | tr " " '\n' | grep -F -q -x "$version"
88+
exit_code="$?"
89+
if [ "$exit_code" -eq "0" ]; then
90+
echo "Version $version is acceptable"
91+
file_version=3.8
92+
echo "version=3.8" >> "$GITHUB_OUTPUT"
93+
echo "name=v$file_version-$size.tar.gz" >> "$GITHUB_OUTPUT"
94+
else
95+
echo "Version $version is not acceptable"
96+
exit 1
97+
fi
98+
6699
- name: Download from blob storage
67100
run: |
68101
mkdir ghes-data
69102
az storage blob download \
70103
--account-name ghesresults \
71104
--container-name ghes-data \
72-
--name v3.8-small-docs.tar.gz \
73-
--file ghes-data/3.8-small-docs.tar.gz \
105+
--name "${{ steps.file.outputs.name }}" \
106+
--file "ghes-data/${{ steps.file.outputs.name }}" \
74107
--connection-string "${{ secrets.CONNECTIONSTRING }}"
75108
76109
- name: Unzip backup and setup symlink
77110
run: |
78111
mkdir "$HOME/ghe-backup-data"
79112
dir_name=$(date +%s)
80113
mkdir "$HOME/ghe-backup-data/$dir_name"
81-
tar -xvf "ghes-data/3.8-small-docs.tar.gz" -C "$HOME/ghe-backup-data/$dir_name"
114+
115+
tar -xvf "ghes-data/${{ steps.file.outputs.name }}" -C "$HOME/ghe-backup-data/$dir_name"
82116
83117
ln -s "$dir_name" "$HOME/ghe-backup-data/current"
84118
@@ -89,7 +123,7 @@ jobs:
89123
run: chmod 0600 "$HOME/backup"
90124

91125
- name: change version
92-
run: echo "3.8.0" > "$HOME/version"
126+
run: echo "${{ inputs.version }}.0" > "$HOME/version"
93127

94128
- name: Prepare for restore
95129
run: ssh -p122 -i "$HOME/backup" -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -s"

0 commit comments

Comments
 (0)