Skip to content

Commit 61bb5fc

Browse files
authored
Merge pull request #653 from github/enterprise-3.10-backport-459-ddivad195/container-prefix-fix
Backport 459 for 3.10: fix: backup and restore actions container prefix
2 parents 5bd1414 + 9b49d3e commit 61bb5fc

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

share/github-backup-utils/ghe-backup-settings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ if ghe-ssh "$host" -- ghe-config --true app.actions.enabled; then
122122
backup-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint"
123123
backup-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" --best-effort
124124
backup-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint"
125+
backup-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix"
125126

126127
backup-secret "Actions Launch secrets encryption/decryption" "actions-launch-secrets-private-key" "secrets.launch.actions-secrets-private-key"
127128
backup-secret "Actions Launch deployer HMAC key" "actions-launch-deployer-hmac" "secrets.launch.deployer-hmac-secret"

share/github-backup-utils/ghe-restore-actions

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ restore-secret "Actions Launch service private key" "actions-launch-app-app-priv
8585
restore-secret "Actions Launch token oauth key" "actions-oauth-s2s-signing-key" "secrets.launch.token-oauth-key"
8686
restore-secret "Actions Launch token oauth cert" "actions-oauth-s2s-signing-cert" "secrets.launch.token-oauth-cert"
8787

88+
# Restore storage container prefix, but only if it exists, and the `-c` option is used with ghe-restore to avoid staging instances using production bucket settings
89+
if [[ $RESTORE_SETTINGS == "true" ]]; then
90+
if [[ -e "$GHE_RESTORE_SNAPSHOT_PATH/actions-storage-container-prefix" ]]; then
91+
restore-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix"
92+
else
93+
log_warn "Actions storage container prefix not present in backup. Skipping ..."
94+
fi
95+
fi
8896

8997
# Setup the database logins.
9098
ghe_verbose "* Restoring database logins and users to $host ..."

test/test-ghe-restore.sh

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,94 @@ begin_test "ghe-restore with Actions settings"
622622
)
623623
end_test
624624

625+
begin_test "ghe-restore with Actions settings passing -c"
626+
(
627+
set -e
628+
rm -rf "$GHE_REMOTE_ROOT_DIR"
629+
setup_remote_metadata
630+
enable_actions
631+
632+
required_files=(
633+
"actions-config-db-login"
634+
"actions-config-db-password"
635+
"actions-framework-access-token"
636+
"actions-url-signing-hmac-key-primary"
637+
"actions-url-signing-hmac-key-secondary"
638+
"actions-oauth-s2s-signing-cert"
639+
"actions-oauth-s2s-signing-key"
640+
"actions-oauth-s2s-signing-cert-thumbprint"
641+
"actions-primary-encryption-cert-thumbprint"
642+
"actions-aad-cert-thumbprint"
643+
"actions-delegated-auth-cert-thumbprint"
644+
"actions-runtime-service-principal-cert"
645+
"actions-s2s-encryption-cert"
646+
"actions-secondary-encryption-cert-thumbprint"
647+
"actions-service-principal-cert"
648+
"actions-sps-validation-cert-thumbprint"
649+
"actions-storage-container-prefix"
650+
651+
"actions-launch-secrets-private-key"
652+
"actions-launch-deployer-hmac"
653+
"actions-launch-client-id"
654+
"actions-launch-client-secret"
655+
"actions-launch-receiver-webhook-secret"
656+
"actions-launch-app-private-key"
657+
"actions-launch-app-public-key"
658+
"actions-launch-app-id"
659+
"actions-launch-app-relay-id"
660+
"actions-launch-action-runner-secret"
661+
"actions-launch-azp-app-cert"
662+
"actions-launch-app-app-private-key"
663+
664+
)
665+
666+
for file in "${required_files[@]}"; do
667+
echo "foo" > "$GHE_DATA_DIR/current/$file"
668+
done
669+
670+
ghe-restore -v -f -c localhost
671+
672+
required_secrets=(
673+
"secrets.actions.ConfigurationDatabaseSqlLogin"
674+
"secrets.actions.ConfigurationDatabaseSqlPassword"
675+
"secrets.actions.FrameworkAccessTokenKeySecret"
676+
"secrets.actions.UrlSigningHmacKeyPrimary"
677+
"secrets.actions.UrlSigningHmacKeySecondary"
678+
"secrets.actions.OAuthS2SSigningCert"
679+
"secrets.actions.OAuthS2SSigningKey"
680+
"secrets.actions.OAuthS2SSigningCertThumbprint"
681+
"secrets.actions.PrimaryEncryptionCertificateThumbprint"
682+
"secrets.actions.AADCertThumbprint"
683+
"secrets.actions.DelegatedAuthCertThumbprint"
684+
"secrets.actions.RuntimeServicePrincipalCertificate"
685+
"secrets.actions.S2SEncryptionCertificate"
686+
"secrets.actions.SecondaryEncryptionCertificateThumbprint"
687+
"secrets.actions.ServicePrincipalCertificate"
688+
"secrets.actions.SpsValidationCertThumbprint"
689+
"secrets.actions.storage.container-prefix"
690+
"secrets.launch.actions-secrets-private-key"
691+
"secrets.launch.deployer-hmac-secret"
692+
"secrets.launch.client-id"
693+
"secrets.launch.client-secret"
694+
"secrets.launch.receiver-webhook-secret"
695+
"secrets.launch.app-private-key"
696+
"secrets.launch.app-public-key"
697+
"secrets.launch.app-id"
698+
"secrets.launch.app-relay-id"
699+
"secrets.launch.action-runner-secret"
700+
"secrets.launch.token-oauth-key"
701+
"secrets.launch.token-oauth-cert"
702+
"secrets.launch.azp-app-cert"
703+
"secrets.launch.azp-app-private-key"
704+
705+
)
706+
707+
for secret in "${required_secrets[@]}"; do
708+
[ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ]
709+
done
710+
)
711+
end_test
712+
625713
begin_test "ghe-restore stops and starts Actions"
626714
(
627715
set -e

0 commit comments

Comments
 (0)