-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
106 lines (99 loc) · 4.82 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: dv-configbaker
description: |
"This GitHub Action serves as a powerful tool to create a functional Dataverse instance, enabling developers to run tests and perform other critical tasks within their GitHub CI workflows."
inputs:
image_tag:
description: "Tag of image for Dataverse app and Configbaker"
required: true
default: "unstable"
image_dataverse:
description: "Name of Dataverse app image (can include registry)"
required: true
default: "docker.io/gdcc/dataverse"
image_configbaker:
description: "Name of Configbaker image (can include registry)"
required: true
default: "docker.io/gdcc/configbaker"
postgresql_version:
description: "Override the PostgreSQL version to use"
required: false
solr_version:
description: "Override the Solr version to use"
required: false
jvm_options:
description: "Line separated key-value pairs of JVM options to be set before startup. Example: dataverse.spi.exporters.directory=/..."
required: false
outputs:
api_token:
description: "API Token of dataverseAdmin superuser"
value: ${{ steps.bootstrap.outputs.API_TOKEN }}
base_url:
description: "Base URL where to reach the instance via HTTP"
value: ${{ steps.bootstrap.outputs.base_url }}
dv_version:
description: "Dataverse version"
value: ${{ steps.bootstrap.outputs.dv_version }}
runs:
using: "composite"
steps:
- name: "Pull images for inspection and cache"
shell: bash
run: |
docker pull -q ${{ inputs.image_dataverse }}:${{ inputs.image_tag }}
docker pull -q ${{ inputs.image_configbaker }}:${{ inputs.image_tag }}
- name: "Prepare environment"
shell: bash
run: |
# Get PostgreSQL version from action config or application image metadata, fail otherwise
PG_VERSION="${{ inputs.postgresql_version }}"
PG_VERSION="${PG_VERSION:-$(docker inspect -f '{{ index .Config.Labels "org.dataverse.deps.postgresql.version"}}' '${{ inputs.image_dataverse }}:${{ inputs.image_tag }}')}"
if [[ -z "${PG_VERSION}" ]]; then
echo "Cannot find PostgreSQL version"; exit 1
else
echo "POSTGRES_VERSION=$PG_VERSION" | tee -a "${GITHUB_ENV}"
fi
# Get Solr version from action config or application image metadata, fail otherwise
SOLR_VERSION=${{ inputs.solr_version }}
SOLR_VERSION="${SOLR_VERSION:-$(docker inspect -f '{{ index .Config.Labels "org.dataverse.deps.solr.version"}}' '${{ inputs.image_dataverse }}:${{ inputs.image_tag }}')}"
if [[ -z "${SOLR_VERSION}" ]]; then
echo "Cannot find Solr version"; exit 1
else
echo "SOLR_VERSION=$SOLR_VERSION" | tee -a "${GITHUB_ENV}"
fi
echo "CONFIGBAKER_IMAGE=${{ inputs.image_configbaker }}:${{ inputs.image_tag }}" | tee -a "${GITHUB_ENV}"
echo "DATAVERSE_IMAGE=${{ inputs.image_dataverse }}:${{ inputs.image_tag }}" | tee -a "${GITHUB_ENV}"
echo "DATAVERSE_DB_USER=dataverse" | tee -a "${GITHUB_ENV}"
echo "DATAVERSE_DB_PASSWORD=secret" | tee -a "${GITHUB_ENV}"
# We use the MicroProfile Config Source trick of reading properties from a directory.
# See also https://docs.payara.fish/community/docs/Technical%20Documentation/MicroProfile/Config/Directory.html
echo "CONFIG_DIR=${RUNNER_TEMP}/dv/conf" | tee -a "${GITHUB_ENV}"
mkdir -p "${RUNNER_TEMP}/dv/conf"
while IFS= read -r line; do
FILENAME="${RUNNER_TEMP}/dv/conf/$(echo "$line" | cut -f1 -d=)"
echo "$line" | cut -f2- -d= > "$FILENAME"
done < <(printf '%s' "${{ inputs.jvm_options }}")
- name: "Start Dataverse service in background"
shell: bash
run: |
echo "::group::🥎 Start Dataverse service in background"
docker compose -f ${{ github.action_path }}/docker-compose.yml -p apitest up -d --quiet-pull \
&& echo -e "✅️ Dataverse containers have been started."
echo "::endgroup::"
# Bootstrap will wait up until accessible, so blocking here.
- name: "Bootstrap Dataverse service"
id: bootstrap
shell: bash
run: |
echo "::group::🤖 Bootstrap Dataverse service"
mkdir -p "${RUNNER_TEMP}/dv"
touch "${RUNNER_TEMP}/dv/bootstrap.exposed.env"
docker run -i --network apitest_dataverse \
-v "${RUNNER_TEMP}/dv/bootstrap.exposed.env:/.env" \
"${CONFIGBAKER_IMAGE}" bootstrap.sh -e /.env dev
# Expose outputs
grep "API_TOKEN" "${RUNNER_TEMP}/dv/bootstrap.exposed.env" >> "$GITHUB_OUTPUT"
echo "base_url=http://localhost:8080/" >> "$GITHUB_OUTPUT"
# Expose version
version=$(curl -s 'http://localhost:8080/api/info/version' | jq -r '.data.version')
echo "dv_version=$version" >>"$GITHUB_OUTPUT"
echo "::endgroup::"