Skip to content

Commit 5108fac

Browse files
authored
Merge pull request #459 from github/ddivad195/container-prefix-fix
fix: backup and restore actions container prefix
2 parents 07c8b3a + 1338786 commit 5108fac

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
@@ -126,6 +126,7 @@ if ghe-ssh "$host" -- ghe-config --true app.actions.enabled; then
126126
backup-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint"
127127
backup-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" --best-effort
128128
backup-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint"
129+
backup-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix"
129130

130131
backup-secret "Actions Launch secrets encryption/decryption" "actions-launch-secrets-private-key" "secrets.launch.actions-secrets-private-key"
131132
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
@@ -674,6 +674,94 @@ begin_test "ghe-restore with Actions settings"
674674
)
675675
end_test
676676

677+
begin_test "ghe-restore with Actions settings passing -c"
678+
(
679+
set -e
680+
rm -rf "$GHE_REMOTE_ROOT_DIR"
681+
setup_remote_metadata
682+
enable_actions
683+
684+
required_files=(
685+
"actions-config-db-login"
686+
"actions-config-db-password"
687+
"actions-framework-access-token"
688+
"actions-url-signing-hmac-key-primary"
689+
"actions-url-signing-hmac-key-secondary"
690+
"actions-oauth-s2s-signing-cert"
691+
"actions-oauth-s2s-signing-key"
692+
"actions-oauth-s2s-signing-cert-thumbprint"
693+
"actions-primary-encryption-cert-thumbprint"
694+
"actions-aad-cert-thumbprint"
695+
"actions-delegated-auth-cert-thumbprint"
696+
"actions-runtime-service-principal-cert"
697+
"actions-s2s-encryption-cert"
698+
"actions-secondary-encryption-cert-thumbprint"
699+
"actions-service-principal-cert"
700+
"actions-sps-validation-cert-thumbprint"
701+
"actions-storage-container-prefix"
702+
703+
"actions-launch-secrets-private-key"
704+
"actions-launch-deployer-hmac"
705+
"actions-launch-client-id"
706+
"actions-launch-client-secret"
707+
"actions-launch-receiver-webhook-secret"
708+
"actions-launch-app-private-key"
709+
"actions-launch-app-public-key"
710+
"actions-launch-app-id"
711+
"actions-launch-app-relay-id"
712+
"actions-launch-action-runner-secret"
713+
"actions-launch-azp-app-cert"
714+
"actions-launch-app-app-private-key"
715+
716+
)
717+
718+
for file in "${required_files[@]}"; do
719+
echo "foo" > "$GHE_DATA_DIR/current/$file"
720+
done
721+
722+
ghe-restore -v -f -c localhost
723+
724+
required_secrets=(
725+
"secrets.actions.ConfigurationDatabaseSqlLogin"
726+
"secrets.actions.ConfigurationDatabaseSqlPassword"
727+
"secrets.actions.FrameworkAccessTokenKeySecret"
728+
"secrets.actions.UrlSigningHmacKeyPrimary"
729+
"secrets.actions.UrlSigningHmacKeySecondary"
730+
"secrets.actions.OAuthS2SSigningCert"
731+
"secrets.actions.OAuthS2SSigningKey"
732+
"secrets.actions.OAuthS2SSigningCertThumbprint"
733+
"secrets.actions.PrimaryEncryptionCertificateThumbprint"
734+
"secrets.actions.AADCertThumbprint"
735+
"secrets.actions.DelegatedAuthCertThumbprint"
736+
"secrets.actions.RuntimeServicePrincipalCertificate"
737+
"secrets.actions.S2SEncryptionCertificate"
738+
"secrets.actions.SecondaryEncryptionCertificateThumbprint"
739+
"secrets.actions.ServicePrincipalCertificate"
740+
"secrets.actions.SpsValidationCertThumbprint"
741+
"secrets.actions.storage.container-prefix"
742+
"secrets.launch.actions-secrets-private-key"
743+
"secrets.launch.deployer-hmac-secret"
744+
"secrets.launch.client-id"
745+
"secrets.launch.client-secret"
746+
"secrets.launch.receiver-webhook-secret"
747+
"secrets.launch.app-private-key"
748+
"secrets.launch.app-public-key"
749+
"secrets.launch.app-id"
750+
"secrets.launch.app-relay-id"
751+
"secrets.launch.action-runner-secret"
752+
"secrets.launch.token-oauth-key"
753+
"secrets.launch.token-oauth-cert"
754+
"secrets.launch.azp-app-cert"
755+
"secrets.launch.azp-app-private-key"
756+
757+
)
758+
759+
for secret in "${required_secrets[@]}"; do
760+
[ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ]
761+
done
762+
)
763+
end_test
764+
677765
begin_test "ghe-restore stops and starts Actions"
678766
(
679767
set -e

0 commit comments

Comments
 (0)