Skip to content

Commit eaaa17c

Browse files
authored
fix running action (#12)
* after previous commit, action was not able to run because files could not be found * converted to composite action, added GITHUB_ACTION_PATH * renamed input to "couchdb-version" (added dash) * bumped couchdb to 3.5
1 parent 365e9cf commit eaaa17c

File tree

6 files changed

+50
-54
lines changed

6 files changed

+50
-54
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Test
22
on:
33
push:
44
branches:
5-
- master
5+
- main
66
pull_request:
77
branches:
8-
- master
8+
- main
99
jobs:
1010
tests:
1111
runs-on: ubuntu-latest
@@ -15,11 +15,11 @@ jobs:
1515
- name: Set up CouchDB
1616
uses: ./
1717
with:
18-
couchdb version: "2.3.1"
18+
couchdb-version: "3.5.0"
1919
- name: Test that CouchDB can be accessed
2020
run: curl -sS -f http://127.0.0.1:5984/
2121
- name: Test that system databases are there
22-
run: curl -sS -f http://127.0.0.1:5984/_users
22+
run: curl -sS -f http://admin:admin@127.0.0.1:5984/_users
2323
- name: Test that the Erlang query server is enabled
2424
run: |
2525
curl -sS -f 'http://admin:[email protected]:5984/_users/_design/test' -X PUT -H 'Content-Type: application/json' --data '{"views":{"test":{"map":"fun({Doc}) -> Emit(proplists:get_value(<<\"name\">>, Doc, null), 1) end."}},"language":"erlang"}'

Dockerfile

Lines changed: 0 additions & 5 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Basic:
1414
```yaml
1515
steps:
1616
- name: Set up CouchDB
17-
uses: "cobot/couchdb-action@master"
17+
uses: "cobot/couchdb-action@main"
1818
with:
1919
couchdb version: "2.3.1"
2020
- name: Do something

action.yml

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
1-
name: 'Setup CouchDB'
2-
description: 'Set up a CouchDB database as a single node.'
3-
author: 'Alexander Lang'
1+
name: "Setup CouchDB"
2+
description: "Set up a CouchDB database as a single node."
3+
author: "Alexander Lang"
44
branding:
5-
icon: 'database'
6-
color: 'red'
5+
icon: "database"
6+
color: "red"
77
inputs:
88
# See https://hub.docker.com/_/couchdb for supported versions
99
# and further details on input environment variables
10-
couchdb version:
11-
description: 'Version of CouchDB to use.'
10+
couchdb-version:
11+
description: "Version of CouchDB to use."
1212
required: false
13-
default: 'latest'
13+
default: "latest"
1414
runs:
15-
using: 'docker'
16-
image: 'Dockerfile'
15+
using: "composite"
16+
steps:
17+
- name: Set up CouchDB
18+
env:
19+
INPUT_COUCHDB_VERSION: ${{ inputs.couchdb-version }}
20+
GITHUB_ACTION_PATH: ${{ github.action_path }}
21+
run: |
22+
sed -i "s/COUCHDB_VERSION/$INPUT_COUCHDB_VERSION/" $GITHUB_ACTION_PATH/Dockerfile.couchdb
23+
docker build --tag custom-couchdb -f $GITHUB_ACTION_PATH/Dockerfile.couchdb $GITHUB_ACTION_PATH
24+
docker run -d -p 5984:5984 -p 5986:5986 --tmpfs /ram_disk custom-couchdb
25+
shell: bash
26+
- name: Wait for CouchDB to be ready
27+
run: $GITHUB_ACTION_PATH/wait-for-couchdb.sh
28+
shell: bash
29+
- name: Set up CouchDB system databases
30+
run: |
31+
curl -sS 'http://admin:[email protected]:5984/_users' -X PUT -H 'Content-Type: application/json' --data '{"id":"_users","name":"_users"}' > /dev/null
32+
curl -sS 'http://admin:[email protected]:5984/_global_changes' -X PUT -H 'Content-Type: application/json' --data '{"id":"_global_changes","name":"_global_changes"}' > /dev/null
33+
curl -sS 'http://admin:[email protected]:5984/_replicator' -X PUT -H 'Content-Type: application/json' --data '{"id":"_replicator","name":"_replicator"}' > /dev/null
34+
shell: bash

entrypoint.sh

Lines changed: 0 additions & 34 deletions
This file was deleted.

wait-for-couchdb.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
echo "Waiting for CouchDB..."
4+
retries=0
5+
max_retries=20
6+
7+
until curl --output /dev/null --silent --head --fail http://127.0.0.1:5984/; do
8+
retries=$((retries+1))
9+
if [ $retries -ge $max_retries ]; then
10+
echo "CouchDB did not become available after $max_retries attempts. Exiting."
11+
exit 1
12+
fi
13+
echo "."
14+
sleep 1
15+
done
16+
17+
echo "CouchDB is up and running."

0 commit comments

Comments
 (0)