Skip to content

Commit cc1e0ef

Browse files
committed
Extract service name from metadata
1 parent 3355306 commit cc1e0ef

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/main.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export async function run(): Promise<void> {
9696
try {
9797
// Get action inputs
9898
const image = getInput('image'); // Image ie gcr.io/...
99-
const service = getInput('service'); // Service name
99+
let service = getInput('service'); // Service name
100100
const job = getInput('job'); // Job name
101101
const metadata = getInput('metadata'); // YAML file
102102
const projectId = getInput('project_id');
@@ -156,6 +156,19 @@ export async function run(): Promise<void> {
156156
const contents = await readFile(metadata, 'utf8');
157157
const parsed = parseYAML(contents);
158158

159+
// Extract service name from metadata template
160+
const name = parsed?.metadata?.name;
161+
if (!name) {
162+
throw new Error(`${metadata} is missing 'metadata.name'`);
163+
}
164+
if (service !== '' && service != name) {
165+
throw new Error(
166+
`service name in ${metadata} ("${name}") does not match GitHub ` +
167+
`Actions service input ("${service}")`,
168+
);
169+
}
170+
service = name;
171+
159172
const kind = parsed?.kind;
160173
if (kind === 'Service') {
161174
deployCmd = ['run', 'services', 'replace', metadata];

0 commit comments

Comments
 (0)