Skip to content
This repository was archived by the owner on Jun 16, 2024. It is now read-only.

Commit 771ad34

Browse files
committed
feat: basic logic to wait for a 200 response
1 parent 0f7e84d commit 771ad34

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+7712
-13
lines changed

.github/workflows/main.yml

+4-7
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@ on: [push]
33
jobs:
44
hello_world_job:
55
runs-on: ubuntu-latest
6-
name: A job to say hello
6+
name: A job to test this action
77
steps:
88
# To use this repository's private action, you must check out the repository
99
- name: Checkout
1010
uses: actions/checkout@v1
11-
- name: Hello world action step
11+
- name: Waiting for 200 response
1212
uses: ./ # Uses an action in the root directory
13-
id: hello
13+
id: waitFor200
1414
with:
15-
who-to-greet: "Mona the Octocat"
16-
# Use the output from the `hello` step
17-
- name: Get the output time
18-
run: echo "The time was ${{ steps.hello.outputs.time }}"
15+
url: "https://jake.partus.ch"

index.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
const core = require("@actions/core");
22
const github = require("@actions/github");
3+
const axios = require("axios");
34

45
try {
5-
// `who-to-greet` input defined in action metadata file
6-
const nameToGreet = core.getInput("who-to-greet");
7-
console.log(`Hello ${nameToGreet}!`);
8-
const time = new Date().toTimeString();
9-
core.setOutput("time", time);
6+
const url = core.getInput("url");
7+
console.log(`Waiting for a 200 from: ${url}`);
8+
9+
for (let i = 0; i < 5; i++) {
10+
try {
11+
await axios.get(url);
12+
} catch (e) {
13+
await new Promise(r => setTimeout(r, 5000));
14+
if (i === 4) {
15+
core.setFailed(`Timeout reached: Unable to connect to ${url}`);
16+
}
17+
}
18+
}
1019
// Get the JSON webhook payload for the event that triggered the workflow
1120
const payload = JSON.stringify(github.context.payload, undefined, 2);
1221
console.log(`The event payload: ${payload}`);

node_modules/axios/CHANGELOG.md

+348
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/axios/LICENSE

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)