Skip to content

Commit

Permalink
Better debug for repo/environment secrets and variables when a value …
Browse files Browse the repository at this point in the history
…is missing
  • Loading branch information
davidcarboni committed Nov 29, 2023
1 parent daac12d commit d010efe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cdk-github/src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export async function setEnvironmentSecret(
repo: string,
environment: string,
): Promise<string> {
if (!secretValue) throw new Error(`No value for secret ${secretName}`);
if (!secretValue) throw new Error(`No value for environment secret ${secretName} (${owner}/${repo} - ${environment})`);
const environmentPublicKey = await getEnvironmentPublicKey(owner, repo, environment);
const encryptedValue = await encrypt(secretValue, environmentPublicKey.key);
const repoId = await getRepoId(owner, repo);
Expand Down Expand Up @@ -135,7 +135,7 @@ export async function setEnvironmentVariable(
repo: string,
environment: string,
): Promise<string> {
if (!value) throw new Error(`No value for variable ${name}`);
if (!value) throw new Error(`No value for environment variable ${name} (${owner}/${repo} - ${environment}))`);
try {
// Most likely we're updating an existing variable:
const response = await octokit.rest.actions.updateEnvironmentVariable({
Expand Down
4 changes: 2 additions & 2 deletions cdk-github/src/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export async function setRepoSecret(
owner: string,
repo: string,
): Promise<string> {
if (!secretValue) throw new Error(`No value for secret ${secretName}`);
if (!secretValue) throw new Error(`No value for repo secret ${secretName} (${owner}/${repo})`);
const publicKey = await getRepoPublicKey(owner, repo);
const encryptedValue = await encrypt(secretValue, publicKey.key);
const response = await octokit.actions.createOrUpdateRepoSecret({
Expand All @@ -137,7 +137,7 @@ export async function setRepoVariable(
owner: string,
repo: string,
): Promise<string> {
if (!value) throw new Error(`No value for variable ${name}`);
if (!value) throw new Error(`No value for repo variable ${name} (${owner}/${repo}))`);
try {
// Most likely we're updating an existing variable:
const response = await octokit.rest.actions.updateRepoVariable({
Expand Down

0 comments on commit d010efe

Please sign in to comment.