Skip to content

Commit 5dd47bd

Browse files
authored
Merge branch 'master' into daxamin-offline-error
2 parents 6396e77 + 0889f59 commit 5dd47bd

File tree

9 files changed

+87
-83
lines changed

9 files changed

+87
-83
lines changed

.github/workflows/backup.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
build:
4848
runs-on: ubuntu-latest
4949
steps:
50-
- uses: actions/checkout@v3
50+
- uses: actions/checkout@v4
5151
with:
5252
repository: github/backup-utils-private
5353
token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}"
@@ -62,7 +62,7 @@ jobs:
6262
needs: build
6363
runs-on:
6464
group: larger-hosted-public-runners
65-
labels: ubuntu-latest-xl
65+
labels: ubuntu-latest
6666
env:
6767
SSH_KEY: ${{ secrets.BACKUP_SSH_KEY }}
6868
steps:
@@ -98,7 +98,7 @@ jobs:
9898
sudo tar -czvf "${{ inputs.backup-name }}.tar.gz" -C "$HOME/ghe-backup-data/$current" .
9999
100100
- name: Login to Azure
101-
if: ${{ inputs.backup-name }} != ""
101+
if: "${{ inputs.backup-name != '' }}"
102102
run: |
103103
az login \
104104
--service-principal \
@@ -108,11 +108,11 @@ jobs:
108108
az account set --subscription "${{ secrets.AZURE_SUBSCRIPTION_ID }}"
109109
110110
- name: Upload backup to Azure
111-
if: ${{ inputs.backup-name }} != ""
111+
if: "${{ inputs.backup-name != '' }}"
112112
run: |
113113
az storage blob upload \
114114
--account-name "${{ secrets.AZURE_ACCOUNT_NAME }}" \
115115
--container-name "${{ secrets.AZURE_CONTAINER_NAME }}" \
116116
--name "${{ inputs.backup-name }}.tar.gz" \
117117
--file "${{ inputs.backup-name }}.tar.gz" \
118-
--connection-string "${{ secrets.CONNECTIONSTRING }}"
118+
--connection-string "${{ secrets.CONNECTIONSTRING }}"

.github/workflows/backuprestore.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
build:
2929
runs-on: ubuntu-latest
3030
steps:
31-
- uses: actions/checkout@v3
31+
- uses: actions/checkout@v4
3232
with:
3333
repository: github/backup-utils-private
3434
ref: ${{ inputs.ref }}
@@ -51,13 +51,13 @@ jobs:
5151
run: docker load -i backup-utils.tar
5252
- uses: actions/checkout@v3
5353
- name: Create backup directory
54-
run: mkdir $HOME/ghe-backup-data
54+
run: mkdir "$HOME"/ghe-backup-data
5555
- name: set up ssh SSH_KEY
56-
run: echo -e "${SSH_KEY}\n" > $HOME/backup
56+
run: echo -e "${SSH_KEY}\n" > "$HOME"/backup
5757
- name: set up ssh key permissions
58-
run: chmod 0600 $HOME/backup
58+
run: chmod 0600 "$HOME"/backup
5959
- name: change version
60-
run: echo "3.8.0" > $HOME/version
60+
run: echo "3.8.0" > "$HOME"/version
6161
- name: Perform backup
6262
run: |
6363
docker run -e "GHE_HOSTNAME=${{ inputs.hostname }}" \
@@ -70,7 +70,7 @@ jobs:
7070
--rm \
7171
backup-utils ghe-backup
7272
- name: Prepare for restore
73-
run: ssh -p122 -i $HOME/backup -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -s"
73+
run: ssh -p122 -i "$HOME"/backup -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -s"
7474
- name: Restore data to instance
7575
run: |
7676
docker run -e "GHE_HOSTNAME=${{ inputs.hostname }}" \
@@ -83,5 +83,5 @@ jobs:
8383
--rm \
8484
backup-utils ghe-restore ${{ inputs.hostname }}
8585
- name: Reset maintenance mode after restore
86-
run: ssh -p122 -i $HOME/backup -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -u"
86+
run: ssh -p122 -i "$HOME"/backup -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -u"
8787

.github/workflows/build-and-release.yml

Lines changed: 36 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ name: Build and Release
44
on:
55
workflow_dispatch:
66
inputs:
7-
gh-token:
8-
description: 'GitHub Token - used to create a commit in the backup-utils repo'
9-
required: true
10-
type: string
117
version:
128
description: 'Version - patch version of the release (e.g. x.y.z)'
139
required: true
@@ -21,22 +17,20 @@ on:
2117
jobs:
2218
build:
2319
runs-on: ubuntu-latest
20+
outputs:
21+
rc-app-token: ${{ steps.app-token.outputs.token }}
2422
steps:
25-
# resulting token still gets denied by the backup-utils repo
26-
# see: https://github.com/actions/create-github-app-token/pull/46
27-
# - uses: timreimherr/create-github-app-token@main
28-
# id: app-token
29-
# with:
30-
# # required
31-
# app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }}
32-
# private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }}
33-
# owner: ${{ github.repository_owner }}
34-
# repositories: backup-utils,backup-utils-private
23+
- uses: actions/create-github-app-token@v1
24+
id: app-token
25+
with:
26+
app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }}
27+
private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }}
28+
owner: ${{ github.repository_owner }}
29+
repositories: "backup-utils-private"
3530
- name: Checkout backup-utils-private
3631
uses: actions/checkout@v4
3732
with:
38-
token: ${{ github.event.inputs.gh-token }}
39-
repository: github/backup-utils-private
33+
token: ${{ steps.app-token.outputs.token }}
4034
- name: Install dependencies
4135
run: |
4236
sudo apt-get update -y
@@ -50,14 +44,6 @@ jobs:
5044
- name: Package deb
5145
run: |
5246
./script/package-deb
53-
# many need to remove this once release-notes compilation is automated
54-
- name: Rename deb artifact
55-
run: |
56-
for file in dist/github-backup-utils_*_all.deb; do
57-
if [[ -f "$file" ]]; then
58-
mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb"
59-
fi
60-
done
6147
- name: Upload deb artifact
6248
uses: actions/upload-artifact@v3
6349
with:
@@ -79,35 +65,40 @@ jobs:
7965
outputs:
8066
commit_hash: ${{ steps.empty-commit.outputs.commit_hash }}
8167
steps:
82-
# resulting token still gets denied by the backup-utils repo
83-
# see: https://github.com/actions/create-github-app-token/pull/46
84-
# - uses: timreimherr/create-github-app-token@main
85-
# id: app-token
86-
# with:
87-
# app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }}
88-
# private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }}
89-
# owner: ${{ github.repository_owner }}
90-
# repositories: backup-utils,backup-utils-private
68+
- uses: actions/create-github-app-token@v1
69+
id: app-token
70+
with:
71+
app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }}
72+
private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }}
73+
owner: ${{ github.repository_owner }}
74+
repositories: "backup-utils,backup-utils-private"
75+
- name: Get major-feature from version
76+
id: get-major-feature
77+
run: |
78+
echo "MAJOR_FEATURE=$(echo ${{ github.event.inputs.version }} | cut -d '.' -f 1,2)" >> "$GITHUB_ENV"
79+
- name: Verify major-feature
80+
run: |
81+
echo "major_feature: $MAJOR_FEATURE"
9182
- name: Checkout backup-utils
9283
uses: actions/checkout@v4
9384
with:
94-
token: ${{ github.event.inputs.gh-token }}
85+
token: ${{ steps.app-token.outputs.token }}
9586
repository: github/backup-utils
96-
ref: master
9787
- name: Create empty commit
9888
uses: stefanzweifel/git-auto-commit-action@v4
9989
id: empty-commit
10090
with:
101-
branch: master
91+
branch: ${{ env.MAJOR_FEATURE }}-stable
10292
commit_message: "${{ github.event.inputs.version }} release"
103-
commit_user_name: "${{ github.actor }}"
104-
commit_user_email: "ghes-releases-team@github.com"
93+
commit_user_name: "release-controller[bot]"
94+
commit_user_email: "223695+release-controller[bot]@users.noreply.github.com"
10595
commit_options: "--allow-empty"
96+
push_options: "--force"
10697
skip_dirty_check: true
107-
- name: Checkout backup-utils
98+
- name: Checkout backup-utils-private for release notes
10899
uses: actions/checkout@v4
109100
with:
110-
token: ${{ github.event.inputs.gh-token }}
101+
token: ${{ steps.app-token.outputs.token }}
111102
repository: github/backup-utils-private
112103
- name: Download deb artifact
113104
uses: actions/download-artifact@v3
@@ -120,20 +111,17 @@ jobs:
120111
- name: Create Release
121112
uses: ncipollo/release-action@v1
122113
with:
123-
token: ${{ github.event.inputs.gh-token }}
114+
token: ${{ steps.app-token.outputs.token }}
115+
owner: github
124116
repo: backup-utils
125117
name: |
126118
GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }}
127119
artifacts: |
128-
github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \
120+
github-backup-utils-v${{ github.event.inputs.version }}.tar.gz,
129121
github-backup-utils_${{ github.event.inputs.version }}_all.deb
130122
tag: v${{ github.event.inputs.version }}
131-
commit: ${{ steps.empty-commit.outputs.commit_hash }}
123+
commit: ${{ env.MAJOR_FEATURE }}-stable
132124
bodyFile: release-notes/${{ github.event.inputs.version }}.md
133125
draft: ${{ github.event.inputs.draft }}
134126
allowUpdates: true
135-
artifactContentType: "raw"
136-
137-
138-
139-
127+
artifactContentType: "raw"

.github/workflows/docker-image.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docker Image CI
1+
name: Docker Image Build CI
22

33
on:
44
push:
@@ -13,16 +13,16 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717
- name: Build the Ubuntu Docker image
18-
run: docker build . --file Dockerfile --tag backup-utils:${GITHUB_RUN_ID}
18+
run: docker build . --file Dockerfile --tag backup-utils:"${GITHUB_RUN_ID}"
1919
- name: Build the Alpine Docker image
20-
run: docker build . --file Dockerfile.alpine --tag backup-utils-alpine:${GITHUB_RUN_ID}
20+
run: docker build . --file Dockerfile.alpine --tag backup-utils-alpine:"${GITHUB_RUN_ID}"
2121
- name: Run tests in Ubuntu Docker image
2222
run: |
23-
docker run backup-utils:${GITHUB_RUN_ID} ghe-backup --version
24-
docker run backup-utils:${GITHUB_RUN_ID} rsync --version
23+
docker run backup-utils:"${GITHUB_RUN_ID}" ghe-backup --version
24+
docker run backup-utils:"${GITHUB_RUN_ID}" rsync --version
2525
- name: Run tests in Alpine Docker image
2626
run: |
27-
docker run backup-utils-alpine:${GITHUB_RUN_ID} ghe-backup --version
28-
docker run backup-utils-alpine:${GITHUB_RUN_ID} rsync --version
27+
docker run backup-utils-alpine:"${GITHUB_RUN_ID}" ghe-backup --version
28+
docker run backup-utils-alpine:"${GITHUB_RUN_ID}" rsync --version

.github/workflows/restore.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
build:
5252
runs-on: ubuntu-latest
5353
steps:
54-
- uses: actions/checkout@v3
54+
- uses: actions/checkout@v4
5555
with:
5656
repository: github/backup-utils-private
5757
ref: ${{ inputs.ref }}
@@ -69,7 +69,7 @@ jobs:
6969
needs: build
7070
runs-on:
7171
group: larger-hosted-public-runners
72-
labels: ubuntu-latest-xl
72+
labels: ubuntu-latest
7373
env:
7474
SSH_KEY: ${{ secrets.BACKUP_SSH_KEY }}
7575
steps:

bin/ghe-backup

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,11 @@ fi
231231

232232
# Output system information of the backup host
233233

234-
# If /etc/issue.net exists, use it to get the OS version
235-
if [ -f /etc/issue.net ]; then
236-
echo "Running on: $(cat /etc/issue.net)"
234+
# If /etc/os-release exists, use it to get the OS version
235+
if [ -f /etc/os-release ]; then
236+
OS_NAME=$(grep '^NAME' /etc/os-release | cut -d'"' -f2)
237+
VERSION_ID=$(grep '^VERSION_ID' /etc/os-release | cut -d'"' -f2)
238+
echo "Running on: $OS_NAME $VERSION_ID"
237239
else
238240
echo "Running on: Unknown OS"
239241
fi

share/github-backup-utils/ghe-backup-config

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -661,17 +661,14 @@ prompt_for_confirmation(){
661661

662662
#initialize progress tracking by clearing out the temp files used to track
663663
init-progress() {
664-
if [ -d /tmp/backup-utils-progress ]; then
664+
665+
if [ -e /tmp/backup-utils-progress ]; then
665666
rm -rf /tmp/backup-utils-progress/*
666667
fi
667668

668-
mkdir -p /tmp/backup-utils-progress
669-
chmod -R 777 /tmp/backup-utils-progress
670-
671-
touch /tmp/backup-utils-progress/total
672-
touch /tmp/backup-utils-progress/type
673-
touch /tmp/backup-utils-progress/progress
674-
touch /tmp/backup-utils-progress/info
669+
# shellcheck disable=SC2174 # We are fine with -m only affecting the deepest directory
670+
mkdir -m 777 -p /tmp/backup-utils-progress
671+
touch /tmp/backup-utils-progress/{total,type,progress,info}
675672
}
676673

677674

share/github-backup-utils/ghe-backup-secrets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ backup-secret() {
5454
log_info "* Transferring $description ..." 1>&3
5555
ghe-ssh "$host" -- ghe-config "$setting" > "$file+" || (
5656
if [ "$best_effort" = "false" ]; then
57-
echo "Warning: $description not set" >&2
57+
echo "Info: $description not set. Skipping..." >&2
5858
fi
5959
)
6060
if [ -n "$(cat "$file+")" ]; then

test/test-ghe-backup.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1068,9 +1068,26 @@ begin_test "ghe-backup collects information on system where backup-utils is inst
10681068
set -e
10691069

10701070
output=$(ghe-backup)
1071-
echo "$output" | grep "Running on: $(cat /etc/issue.net)"
1071+
OS_NAME=$(grep '^NAME' /etc/os-release | cut -d'"' -f2)
1072+
VERSION_ID=$(grep '^VERSION_ID' /etc/os-release | cut -d'"' -f2)
1073+
echo "$output" | grep "Running on: $OS_NAME $VERSION_ID"
10721074
echo "$output" | grep "CPUs: $(nproc)"
10731075
echo "$output" | grep "Memory total/used/free+share/buff/cache:"
10741076

10751077
)
10761078
end_test
1079+
1080+
# Check that backup-utils manages track-progress folder correctly
1081+
begin_test "ghe-backup manages progress tracking files properly"
1082+
(
1083+
set -e
1084+
1085+
if [ -e /tmp/backup-utils-progress ]; then
1086+
rm -rf /tmp/backup-utils-progress/*
1087+
fi
1088+
1089+
output=$(ghe-backup)
1090+
echo "$output" | grep -v "mkdir: cannot create directory /tmp/backup-utils-progress: File exists"
1091+
1092+
)
1093+
end_test

0 commit comments

Comments
 (0)