Skip to content

Commit 2d271ed

Browse files
committed
fix: do not check if the previous state is "started"
Solves the following scenario: - Publisher triggers a workflow run - Workflow pings Publisher back with "started" state - Publisher isn't yet available via http (probably due to some Lagoon delays) - Publisher does not receive "started" state - After a full build Publisher receives "finished" state - Yet, because of "previous === 'started'" check, it does not react to it - So it waits for the timeout and then, after the timeout is fired, starts a new full build
1 parent 7712303 commit 2d271ed

File tree

1 file changed

+5
-10
lines changed
  • packages/npm/@amazeelabs/publisher/src/mode-github-workflow

1 file changed

+5
-10
lines changed

packages/npm/@amazeelabs/publisher/src/mode-github-workflow/tasks.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
ApplicationState,
55
WorkflowPublisherPayload,
66
} from '@amazeelabs/publisher-shared';
7-
import { pairwise } from 'rxjs';
87

98
import { getConfigGithubWorkflow as config } from '../tools/config';
109
import { saveBuildInfo } from '../tools/database';
@@ -107,27 +106,23 @@ async function runWorkflow(args: {
107106
}
108107

109108
const subscription = core.state.workflowState$
110-
.pipe(pairwise())
111-
.subscribe(([previous, current]) => {
112-
if (current === 'started') {
109+
.subscribe((state) => {
110+
if (state === 'started') {
113111
core.output$.next('Workflow started', 'info');
114112
core.output$.next('Logs: ' + core.state.workflowRunUrl);
115113
return;
116114
}
117-
if (
118-
previous === 'started' &&
119-
(current === 'success' || current === 'failure')
120-
) {
115+
if (state === 'success' || state === 'failure') {
121116
subscription.unsubscribe();
122-
if (current === 'success') {
117+
if (state === 'success') {
123118
core.output$.next('Workflow succeeded', 'success');
124119
} else {
125120
core.output$.next('Workflow failed or cancelled', 'error');
126121
}
127122
core.output$.next('Logs: ' + core.state.workflowRunUrl);
128123

129124
clearTimeout(timeout);
130-
return resolve(current === 'success');
125+
return resolve(state === 'success');
131126
}
132127
});
133128
});

0 commit comments

Comments
 (0)