-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert to Github Action #120
Draft
elijahboston
wants to merge
11
commits into
vishnubob:master
Choose a base branch
from
elijahboston:convert-to-action
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7cc5f83
Convert to Github Action
elijahboston ccd8874
use local action
elijahboston d695acb
checkout first
elijahboston 7862761
make executable
elijahboston c40d175
fix branch name
elijahboston 8eb2a13
use mini_httpd
elijahboston 8102ecb
use bash
elijahboston bd5c38d
install bash
elijahboston 68ca9ef
format
elijahboston 02bdf14
format
elijahboston ad1b8f2
use httpd service
elijahboston File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
wait_for_it: | ||
runs-on: ubuntu-latest | ||
name: Ensure action works | ||
services: | ||
test-site-80: | ||
image: httpd | ||
options: >- | ||
-p 3000 | ||
test-site-3000: | ||
image: httpd | ||
options: >- | ||
-p 3000 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Defaults | ||
uses: ./ | ||
with: | ||
host: test-site-80 | ||
- name: Non-default port | ||
uses: ./ | ||
with: | ||
host: test-site-3000 | ||
port: 3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Container image that runs your code | ||
FROM alpine:3.15 | ||
RUN apk add bash | ||
# Copies your code file from your action repository to the filesystem path `/` of the container | ||
COPY wait-for-it.sh /wait-for-it.sh | ||
RUN chmod +x wait-for-it.sh | ||
|
||
# Code file to execute when the docker container starts up (`entrypoint.sh`) | ||
ENTRYPOINT ["/bin/bash", "-c", "/wait-for-it.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,28 @@ | ||
# wait-for-it | ||
# wait-for-it.sh Github Action | ||
|
||
`wait-for-it.sh` is a pure bash script that will wait on the availability of a | ||
host and TCP port. It is useful for synchronizing the spin-up of | ||
interdependent services, such as linked docker containers. Since it is a pure | ||
bash script, it does not have any external dependencies. | ||
|
||
## Usage | ||
`wait-for-it.sh` is a pure bash script to wait on the availability of a host and TCP port. | ||
|
||
```text | ||
wait-for-it.sh host:port [-s] [-t timeout] [-- command args] | ||
-h HOST | --host=HOST Host or IP under test | ||
-p PORT | --port=PORT TCP port under test | ||
Alternatively, you specify the host and port as host:port | ||
-s | --strict Only execute subcommand if the test succeeds | ||
-q | --quiet Don't output any status messages | ||
-t TIMEOUT | --timeout=TIMEOUT | ||
Timeout in seconds, zero for no timeout | ||
-- COMMAND ARGS Execute command with args after the test finishes | ||
``` | ||
|
||
## Examples | ||
Since it is a pure | ||
bash script, it does not have any external dependencies. | ||
|
||
For example, let's test to see if we can access port 80 on `www.google.com`, | ||
and if it is available, echo the message `google is up`. | ||
This Github Action is based on a fork of the original [wait-for-it.sh](https://github.com/vishnubob/wait-for-it), and simply adds the `Dockerfile` and `action.yaml` needed to configure the shell script for use. | ||
|
||
```text | ||
$ ./wait-for-it.sh www.google.com:80 -- echo "google is up" | ||
wait-for-it.sh: waiting 15 seconds for www.google.com:80 | ||
wait-for-it.sh: www.google.com:80 is available after 0 seconds | ||
google is up | ||
## Usage | ||
``` | ||
|
||
You can set your own timeout with the `-t` or `--timeout=` option. Setting | ||
the timeout value to 0 will disable the timeout: | ||
|
||
```text | ||
$ ./wait-for-it.sh -t 0 www.google.com:80 -- echo "google is up" | ||
wait-for-it.sh: waiting for www.google.com:80 without a timeout | ||
wait-for-it.sh: www.google.com:80 is available after 0 seconds | ||
google is up | ||
- id: wait-for-it | ||
runs: elijahboston/wait-for-it | ||
with: | ||
host: localhost | ||
port: 80 | ||
timeout: 60 | ||
strict: false | ||
quiet: false | ||
``` | ||
|
||
The subcommand will be executed regardless if the service is up or not. If you | ||
wish to execute the subcommand only if the service is up, add the `--strict` | ||
argument. In this example, we will test port 81 on `www.google.com` which will | ||
fail: | ||
|
||
```text | ||
$ ./wait-for-it.sh www.google.com:81 --timeout=1 --strict -- echo "google is up" | ||
wait-for-it.sh: waiting 1 seconds for www.google.com:81 | ||
wait-for-it.sh: timeout occurred after waiting 1 seconds for www.google.com:81 | ||
wait-for-it.sh: strict mode, refusing to execute subprocess | ||
Most parameters are optional, only the host is required: | ||
``` | ||
|
||
If you don't want to execute a subcommand, leave off the `--` argument. This | ||
way, you can test the exit condition of `wait-for-it.sh` in your own scripts, | ||
and determine how to proceed: | ||
|
||
```text | ||
$ ./wait-for-it.sh www.google.com:80 | ||
wait-for-it.sh: waiting 15 seconds for www.google.com:80 | ||
wait-for-it.sh: www.google.com:80 is available after 0 seconds | ||
$ echo $? | ||
0 | ||
$ ./wait-for-it.sh www.google.com:81 | ||
wait-for-it.sh: waiting 15 seconds for www.google.com:81 | ||
wait-for-it.sh: timeout occurred after waiting 15 seconds for www.google.com:81 | ||
$ echo $? | ||
124 | ||
- id: wait-for-it | ||
runs: elijahboston/wait-for-it | ||
with: | ||
host: localhost | ||
``` | ||
|
||
## Community | ||
|
||
*Debian*: There is a [Debian package](https://tracker.debian.org/pkg/wait-for-it). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: 'wait-for-it' | ||
description: 'Wait for a response' | ||
inputs: | ||
host: | ||
description: 'Host or IP under test' | ||
required: true | ||
port: | ||
description: 'TCP port under test, default: 80' | ||
required: false | ||
default: '80' | ||
strict: | ||
description: 'Only execute subcommand if the test succeeds' | ||
required: false | ||
default: 'false' | ||
timeout: | ||
description: 'Timeout in seconds, zero for no timeout' | ||
required: false | ||
default: '60' | ||
command: | ||
description: 'Execute command after the test has completed' | ||
required: false | ||
quiet: | ||
description: "Don't output any status messages" | ||
required: false | ||
default: 'false' | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
args: | ||
- --host=${{ inputs.host }} | ||
- --port=${{ inputs.port }} | ||
- --strict=${{ inputs.strict }} | ||
- --timeout=${{ inputs.timeout }} | ||
- --quiet=${{ inputs.quiet }} | ||
- -- ${{ inputs.command }} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this? Adding a GitHub action is ok, but removing the current purpose of this script is against the role of this project.