Skip to content

Commit 8ff0865

Browse files
authored
Allow port flexibility (#4)
Signed-off-by: Derek Ho <[email protected]>
1 parent 7937c24 commit 8ff0865

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

.github/workflows/test.yml

+19
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,25 @@ jobs:
2323
run: curl http://localhost:9200/_cat/plugins -v
2424
shell: bash
2525

26+
test-no-plugins-port-9201:
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
platform: [windows-latest, ubuntu-latest]
31+
runs-on: ${{ matrix.platform }}
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- uses: ./ # Use the action
36+
with:
37+
opensearch-version: 3.0.0
38+
security-enabled: false
39+
port: 9201
40+
41+
- name: Checks that OpenSearch is healthy
42+
run: curl http://localhost:9201/_cat/plugins -v
43+
shell: bash
44+
2645
test-with-security:
2746
strategy:
2847
fail-fast: false

action.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ inputs:
2222
description: 'Path to a security config file to replace the default. Leave empty if security is not enabled or using the default config'
2323
required: false
2424

25-
opensearch_yml_file:
26-
description: 'Path to a opensearch.yml file to replace the default. Leave empty to use the default config'
25+
port:
26+
description: 'Port to run OpenSearch. Leave empty to use the default config (9200)'
2727
required: false
2828

2929
runs:
@@ -127,9 +127,9 @@ runs:
127127
shell: bash
128128

129129
- name: Replace opensearch.yml file if applicable
130-
if: ${{ inputs.opensearch_yml_file != '' }}
130+
if: ${{ inputs.port != '' }}
131131
run: |
132-
mv ${{ inputs.opensearch_yml_file }} ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml
132+
echo -e "\nhttp.port: ${{ inputs.port }}" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml
133133
shell: bash
134134

135135
# Run OpenSearch
@@ -154,9 +154,9 @@ runs:
154154
if: ${{ runner.os != 'Windows'}}
155155
run: |
156156
if [ "${{ inputs.security-enabled }}" == "true" ]; then
157-
curl https://localhost:9200/_cat/plugins -u 'admin:${{ inputs.admin-password }}' -k -v --fail-with-body
157+
curl https://localhost:${{ inputs.port || 9200 }}/_cat/plugins -u 'admin:${{ inputs.admin-password }}' -k -v --fail-with-body
158158
else
159-
curl http://localhost:9200/_cat/plugins -v
159+
curl http://localhost:${{ inputs.port || 9200 }}/_cat/plugins -v
160160
fi
161161
shell: bash
162162

@@ -168,10 +168,10 @@ runs:
168168
$encodedCredentials = [Convert]::ToBase64String($credentialBytes)
169169
$baseCredentials = "Basic $encodedCredentials"
170170
$Headers = @{ Authorization = $baseCredentials }
171-
$url = 'https://localhost:9200/_cat/plugins'
171+
$url = 'https://localhost:${{ inputs.port || 9200 }}/_cat/plugins'
172172
} else {
173173
$Headers = @{ }
174-
$url = 'http://localhost:9200/_cat/plugins'
174+
$url = 'http://localhost:${{ inputs.port || 9200 }}/_cat/plugins'
175175
}
176176
Invoke-WebRequest -SkipCertificateCheck -Uri $url -Headers $Headers;
177177
shell: pwsh

0 commit comments

Comments
 (0)