Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions src/methods/env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@ describe('getEnv', () => {
expect(() => getEnv()).toThrow(/DEVICE_CLOUD_API_KEY is not set/);
});

it('points to an EAS environment variable, not a GitHub Actions secret', () => {
// EAS Workflows have no secrets context, so a step env: block reading
// ${{ secrets.X }} can't supply the key.
vi.stubEnv('DEVICE_CLOUD_API_KEY', '');
let message = '';
try {
getEnv();
} catch (error) {
message = (error as Error).message;
}
expect(message).toContain(
'eas env:create --scope project --environment production'
);
expect(message).toContain(
'--name DEVICE_CLOUD_API_KEY --visibility secret'
);
expect(message).not.toMatch(/env:` block/);
});

it('returns the api key and an empty metadata list when no DCD_* vars are set', () => {
vi.stubEnv('DEVICE_CLOUD_API_KEY', 'secret-key');
const env = getEnv();
Expand Down
13 changes: 11 additions & 2 deletions src/methods/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,18 @@ const metadataMappings: Array<[envVar: string, metadataKey: string]> = [
export function getEnv(): EasEnv {
const apiKey = process.env.DEVICE_CLOUD_API_KEY;
if (!apiKey) {
// EAS Workflows have no secrets context: a job gets the EAS environment
// variables of the environment it runs in (its `environment:`).
throw new Error(
'DEVICE_CLOUD_API_KEY is not set. Pass it via the step `env:` block: ' +
'DEVICE_CLOUD_API_KEY: ${{ secrets.DEVICE_CLOUD_API_KEY }}'
'DEVICE_CLOUD_API_KEY is not set. Store your DeviceCloud API key as an ' +
'EAS environment variable with secret visibility, in the environment ' +
'the job runs in (its `environment:`, production by default), and ' +
'EAS sets it for every step. For example: eas env:create --scope ' +
'project --environment production --environment preview ' +
'--environment development --name DEVICE_CLOUD_API_KEY ' +
'--visibility secret --type string --value <your-api-key>. ' +
"Don't use ${{ secrets.DEVICE_CLOUD_API_KEY }}: EAS Workflows " +
"don't support it."
);
}

Expand Down
Loading
Loading