feat: add scoped image sync endpoint
This commit is contained in:
@@ -77,6 +77,22 @@ export class GitService {
|
||||
});
|
||||
}
|
||||
|
||||
async deploySync({ requestKey, expectedCommit }) {
|
||||
return this.enqueue(async () => {
|
||||
if (this.state.syncRequests.includes(requestKey)) {
|
||||
return { duplicate: true, ...this.publicStatus() };
|
||||
}
|
||||
const result = await this.#deploy({
|
||||
branch: this.state.activeBranch,
|
||||
expectedCommit,
|
||||
allowUnrelated: false,
|
||||
});
|
||||
this.state.syncRequests = [...this.state.syncRequests.slice(-199), requestKey];
|
||||
await this.#saveState();
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
async #deploy({ branch, expectedCommit, allowUnrelated }) {
|
||||
this.#validateBranch(branch);
|
||||
await this.#assertClean();
|
||||
@@ -163,6 +179,7 @@ export class GitService {
|
||||
activeBranch: saved.activeBranch ?? this.config.defaultBranch,
|
||||
deliveries: Array.isArray(saved.deliveries) ? saved.deliveries : [],
|
||||
adminRequests: Array.isArray(saved.adminRequests) ? saved.adminRequests : [],
|
||||
syncRequests: Array.isArray(saved.syncRequests) ? saved.syncRequests : [],
|
||||
lastSuccess: saved.lastSuccess ?? null,
|
||||
lastError: saved.lastError ?? null,
|
||||
};
|
||||
@@ -174,6 +191,7 @@ export class GitService {
|
||||
activeBranch: this.config.defaultBranch,
|
||||
deliveries: [],
|
||||
adminRequests: [],
|
||||
syncRequests: [],
|
||||
lastSuccess: null,
|
||||
lastError: null,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user