Skip to content

Commit cfc7aaf

Browse files
authored
fix: introduce per-job cert volume with %gcl% token (#1877)
1 parent 846456e commit cfc7aaf

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

src/job.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,10 @@ If you know what you're doing and would like to suppress this warning, use one o
468468
return this.jobData["needs"] ?? null;
469469
}
470470

471+
get certVolumeName (): string {
472+
return `gcl-${this.safeJobName}-${this.jobId}-cert`;
473+
}
474+
471475
get buildVolumeName (): string {
472476
return `gcl-${this.safeJobName}-${this.jobId}-build`;
473477
}
@@ -690,10 +694,15 @@ If you know what you're doing and would like to suppress this warning, use one o
690694
const fileVariablesDir = this.fileVariablesDir;
691695

692696
this._containerVolumeNames.push(buildVolumeName, tmpVolumeName);
693-
await Promise.all([
697+
const volumeCreatePromises = [
694698
Utils.spawn([this.argv.containerExecutable, "volume", "create", `${buildVolumeName}`], argv.cwd),
695699
Utils.spawn([this.argv.containerExecutable, "volume", "create", `${tmpVolumeName}`], argv.cwd),
696-
]);
700+
];
701+
if (this.argv.volume.some(v => v.startsWith("%gcl-cert%:"))) {
702+
this._containerVolumeNames.push(this.certVolumeName);
703+
volumeCreatePromises.push(Utils.spawn([this.argv.containerExecutable, "volume", "create", this.certVolumeName], argv.cwd));
704+
}
705+
await Promise.all(volumeCreatePromises);
697706

698707
const time = process.hrtime();
699708
this.refreshLongRunningSilentTimeout(writeStreams);
@@ -1027,7 +1036,8 @@ If you know what you're doing and would like to suppress this warning, use one o
10271036
dockerCmd += `--workdir ${this.ciProjectDir} `;
10281037

10291038
for (const volume of this.argv.volume) {
1030-
dockerCmd += `--volume ${volume} `;
1039+
const v = volume.startsWith("%gcl-cert%:") ? `${this.certVolumeName}${volume.slice("%gcl-cert%".length)}` : volume;
1040+
dockerCmd += `--volume ${v} `;
10311041
}
10321042

10331043
for (const extraHost of this.argv.extraHost) {
@@ -1626,7 +1636,8 @@ If you know what you're doing and would like to suppress this warning, use one o
16261636
}
16271637

16281638
for (const volume of this.argv.volume) {
1629-
dockerCmd += `--volume ${volume} `;
1639+
const v = volume.startsWith("%gcl-cert%:") ? `${this.certVolumeName}${volume.slice("%gcl-cert%".length)}` : volume;
1640+
dockerCmd += `--volume ${v} `;
16301641
}
16311642

16321643
for (const extraHost of this.argv.extraHost) {

0 commit comments

Comments
 (0)