Skip to content

Commit 24dac2a

Browse files
author
CodingNagger
committed
Fix wait end condition
1 parent c47eb3f commit 24dac2a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Install Nginx pod
3636
run: kubectl apply -f https://k8s.io/examples/application/deployment.yaml
3737
- name: Wait for pods
38-
uses: CodingNagger/minikube-wait-action@v1.0.0
38+
uses: CodingNagger/minikube-wait-action@v1.0.1
3939
- name: Check pods
4040
run: |
4141
kubectl get pods

src/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
const core = require('@actions/core');
22
const { spawnSync } = require('child_process');
33

4-
const successMessage = '';
54
const maxRetryAttempts = parseInt(`${core.getInput('max-retry-attempts')}`);
65
const retryDelay = parseInt(`${core.getInput('retry-delay')}`);
76

87
function checkPodsAreUp() {
98
var lastCommandRunning = spawnSync('kubectl', ['get', 'pods','--field-selector=status.phase!=Running,status.phase!=Completed']);
10-
var output = lastCommandRunning.stdout.toString();
9+
var errorOutput = lastCommandRunning.stderr.toString();
10+
var defaultOutput = lastCommandRunning.stdout.toString();
1111
return {
12-
success: `${output}`.trim() == '',
13-
message: output,
12+
success: errorOutput.includes('No resources found'),
13+
message: defaultOutput,
1414
};
1515
}
1616

@@ -28,7 +28,7 @@ try {
2828
var result = checkPodsAreUp();
2929
var attemptsCount = 0;
3030

31-
while(!result.success || attemptsCount < maxRetryAttempts) {
31+
while(!result.success && attemptsCount < maxRetryAttempts) {
3232
console.log(`Waiting ${retryDelay} seconds`);
3333
attemptsCount++;
3434
wait(retryDelay);

0 commit comments

Comments
 (0)